简体   繁体   English

如何在TabActivity中切换其他Activity的Activity

[英]How to destroy the Activity on switching other Activity in TabActivity

I have 3 activity I want to destroy the earlier activity when i move to new 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)); 

Don't use Tab Activity then(TabActivity is deprecated now). 然后不要使用Tab Activity(现在不推荐使用TabActivity)。

Simply create three activities and place three buttons at the bottom of each activity. 只需创建三个活动,并在每个活动的底部放置三个按钮。

and while switching from one activity to another just call finish() after startActivity() . 当从一个活动切换到另一个活动时,只需在startActivity()之后调用finish() startActivity()

I am again saying not to use TabActivity because i have used it in one of my project an that was a headache for me. 我再次说不要使用TabActivity,因为我在我的一个项目中使用它,这对我来说很头疼。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM