【发布时间】:2012-08-30 06:51:17
【问题描述】:
1这是我的代码sn-p
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>`
从我的图像显示,当我按下按钮时,活动在特定部分显示,最后一个活动在活动中保持不变。所以当我按下选项卡按钮时如何覆盖该活动。
【问题讨论】:
-
“意图没有覆盖主要活动”是什么意思?
-
如果您在按下标签按钮时看到图像,则活动正在底部加载,但不是全屏。之前的活动仍然在屏幕上。
-
每项活动都会发生这种情况吗?
-
是的,这发生在我按下的每个标签按钮中
-
向我们展示您的清单文件。还有,看看this 教程
标签: android android-intent android-widget android-tabhost