1这是我的代码片段
TabHost tabHost = getTabHost();
TabSpec aboutus = tabHost.newTabSpec("About us");
aboutus.setIndicator("___", getResources().getDrawable(R.drawable.icon_aboutus_tab));
Intent photosIntent = new Intent(getApplicationContext(), readmore.class);
aboutus.setContent(photosIntent);
TabSpec contactus = tabHost.newTabSpec("Contact us");
// setting Title and Icon for the Tab
contactus.setIndicator("___", getResources().getDrawable(R.drawable.icon_contactus_tab));
Intent songsIntent = new Intent(getApplicationContext(), contactus.class);
contactus.setContent(songsIntent);
TabSpec orderhistory = tabHost.newTabSpec("Order history");
orderhistory.setIndicator("___", getResources().getDrawable(R.drawable.icon_orderhistory_tab));
Intent videosIntent = new Intent(getApplicationContext(), readmore.class);
orderhistory.setContent(videosIntent);
TabSpec home = tabHost.newTabSpec("Home");
home.setIndicator("___", getResources().getDrawable(R.drawable.icon_home_tab));
Intent homeIntent = new Intent(getApplicationContext(), Mainpage.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
home.setContent(homeIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(aboutus); // Adding about us tab
tabHost.addTab(contactus); // Adding contact us tab
tabHost.addTab(orderhistory); // Adding order history tab
tabHost.addTab(home);
Intent 没有覆盖主要活动。我应该如何覆盖它。
这是我的清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhive.xmlparsing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/zaggleicon"
android:label="@string/app_name"
android:name=".MyApplication"
android:theme="@android:style/Theme.Light"
>`<activity
android:label="@string/app_name"
android:name=".AndroidTabLayoutActivity" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>`<activity
android:label="@string/app_name"
android:name=".readmore" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>` <activity android:name=".Mainpage">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>`<activity
android:label="@string/app_name"
android:name=".contactus" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>`
从我的图像中可以看出,当我按下按钮时,活动显示在特定部分,最后一个活动在活动中保持不变。所以当我按下选项卡按钮时如何覆盖该活动。