Tabhost加载所有标签?

时间:2013-11-16 10:59:28

标签: android android-tabhost

我正在创建一个包含3个标签的tabhost,但它同时加载所有标签..我只想加载选定的标签?

请帮忙

代码

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Resources ressources = getResources(); 
    TabHost tabHost = getTabHost(); 





    // Users tab
            Intent intentAndroid = new Intent().setClass(this, UsersOnMap.class);
            TabSpec tabSpecAndroid = tabHost
              .newTabSpec("Users On Map")
              .setContent(intentAndroid);
            tabSpecAndroid.setIndicator("Users On Map",getResources().getDrawable(android.R.drawable.ic_dialog_map));

            tabHost.addTab(tabSpecAndroid);     


     //Users List

            Intent intentAndroid1 = new Intent().setClass(this, UserList.class);
            TabSpec tabSpecAndroid1 = tabHost
              .newTabSpec("Users List")
              .setContent(intentAndroid1);
            tabSpecAndroid1.setIndicator("Users List",getResources().getDrawable(android.R.drawable.ic_menu_sort_by_size));

            tabHost.addTab(tabSpecAndroid1);     



    //History tab
            Intent intentBus = new Intent().setClass(this, History.class);
            TabSpec tabSpecBus = tabHost
                    .newTabSpec("History")
                    .setContent(intentBus);
            tabSpecBus.setIndicator("History",getResources().getDrawable(android.R.drawable.ic_dialog_dialer));
            tabHost.addTab(tabSpecBus);   


            int his=getIntent().getIntExtra("his", 0);

            if(his==1)
            tabHost.setCurrentTab(2);





}

0 个答案:

没有答案