小编use*_*576的帖子

TabActivity在选项卡更改时销毁每个选项卡的活动

TabActivity中的问题我的应用程序中有三个选项卡,每个选项卡都有不同的活动.在第一个选项卡中,我有一个textfield和listview用户搜索但是在搜索之后用户更改了选项卡并再次返回到搜索选项卡时,列表和文本框将被清除.

但我想仍然是人口.标签栏对活动的破坏程度如何?停止?暂停?我不知道有没有办法做到这一点谢谢.

public class MainTab extends TabActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab);
        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);            

        TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
        TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
        TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");

        /* TabSpec setIndicator() is used to set name for the tab. */
        /* TabSpec setContent() is used to set content for a particular tab. */
        firstTabSpec.setIndicator("",getResources().getDrawable(R.drawable.search)).setContent(new Intent(this,Search.class));
        secondTabSpec.setIndicator("",getResources().getDrawable(R.drawable.manager)).setContent(new Intent(this,Manager.class));
        thirdTabSpec.setIndicator("",getResources().getDrawable(R.drawable.settings)).setContent(new Intent(this,Settings.class));

        tabHost.addTab(firstTabSpec);
        tabHost.addTab(secondTabSpec);
        tabHost.addTab(thirdTabSpec);
…………………
Run Code Online (Sandbox Code Playgroud)

代码与普通tabbar所需的代码相同....如果我们手动保存每个类的实例我会很难在活动中有很多数据

android tabbar

1
推荐指数
1
解决办法
2609
查看次数

标签 统计

android ×1

tabbar ×1