[英]How to destroy the Activity on switching other Activity in TabActivity
當我移動到TabActivity中的新活動時,我有3個活動要銷毀之前的活動
TabHosttabHost = getTabHost();
Intent in1 = new Intent(this, ActivityA.class);
// adding each tab details to tabhost
tabHost.addTab(tabHost
.newTabSpec("1")
.setIndicator("TAB3",
getResources().getDrawable(R.drawable.tab1))
.setContent(it5));
Intent it5 = new Intent(this, ActivityB.class);
// adding each tab details to tabhost
Intent in2 = new Intent(this, ActivityB.class);
tabHost.addTab(tabHost
.newTabSpec("2")
.setIndicator("TAB3",
getResources().getDrawable(R.drawable.tab2))
.setContent(it5));
Intent it5 = new Intent(this, ActivityC.class);
// adding each tab details to tabhost
Intent in3 = new Intent(this, ActivityC.class);
tabHost.addTab(tabHost
.newTabSpec("3")
.setIndicator("TAB3",
getResources().getDrawable(R.drawable.tab3))
.setContent(it5));
然后不要使用Tab Activity(現在不推薦使用TabActivity)。
只需創建三個活動,並在每個活動的底部放置三個按鈕。
當從一個活動切換到另一個活動時,只需在startActivity()
之后調用finish()
startActivity()
。
我再次說不要使用TabActivity,因為我在我的一個項目中使用它,這對我來說很頭疼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.