我有这个问题,我已经缩小到行:奇怪的XML问题工作在2.1
setContentView(R.layout.tabs);
代码
:
public class Tabs extends Activity {
Activity currentActivity;
TabHost tabHost;
TabWidget tabWidget;
BrRefreshBarView refreshBar;
BrRSSView newsView;
BrRSSView blogView;
BrSplashLayout splashLayout;
BrImageView splashImage;
BrProgressBar loadingBar;
BrRSS newsrss;
LinearLayout toolbar;
BrRSS blogrss;
LoadRSSTask _initTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BrScreenMetrics.setMetrics(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tabs);
// currentActivity = this;
//
// tabHost = (TabHost)findViewById(android.R.id.tabhost);
// tabWidget = (TabWidget)findViewById(android.R.id.tabs);
//
// tabHost.setup();
// tabHost.setBackgroundColor(0x00000000);
这是我tabs.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="65dip"
android:layout_marginLeft="0dip" android:layout_marginRight="0dip"
android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout android:id="@+id/toolbar"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:visibility="visible"
android:layout_weight="0" android:gravity="bottom" />
</LinearLayout>
</TabHost>
</RelativeLayout>
基本上在2.1它只是立即崩溃与xml中的该TabHost块,没有在logcat。然而在2.2中,它完美地工作。
这里是清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.brickit.farsta"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:icon="@drawable/icons_appicon" android:label="@string/app_name">
<activity android:name=".main"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Tabs" android:label="Tabs">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.TABS"/>
</intent-filter>
</activity>
<activity android:name="se.brickit.internal.BrRSSDetailActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
我做了几乎从谷歌教程复制品,但更详细的,它适用于我。 [链接](http://subspider-mobile.blogspot.com/) – PedroAGSantos 2011-06-08 07:09:55