我有這個問題,我已經縮小到行:奇怪的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