简体   繁体   English

android:先添加空白标签,然后再设置内容

[英]android: add empty tab first and set content later

In the example below, is there a way to add an empty tab first and set the content later when args value is not null? 在下面的示例中,是否有一种方法可以在args值不为null时先添加一个空白标签,然后再设置内容?

public class MainActivity extends FragmentActivity {
private FragmentTabHost mTabHost;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    .........//more code
     Bundle args = new Bundle();
     args.putSerializable("arguments", object);
     ..................

    mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("Tab1"),
        Tab1Fragment.class, args);
    mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("Tab2"),
        Tab2Fragment.class, args);
    mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("Tab3"),
        Tab3Fragment.class, args);
}
}

根据FragmentTabHost的android api文档,在争论不为null时添加选项卡,并使用设置方法

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

相关问题 Android将内容添加到“自定义”标签 - Android Add content to Custom Tab android actionbar选项卡视图页AsyncTask启动时第一个选项卡为空 - android actionbar tab viewpage AsyncTask first tab is empty when started 使用Tabhost android在第二个选项卡中显示的第一个选项卡内容 - first tab content displayed in second tab using Tabhost android 适用于4.0和更高版本的Android Tab图标 - Android Tab icon for 4.0 and later Android,如何将第一个标签始终设置为默认标签 - Android, how to set first tab as a default tab always android:empty的内容未在选项卡布局的listview中显示 - content for android:empty isn't shown in listview in tab layout 具有Tabhost的Android FragmentActivity不显示第一个标签的内容 - Android FragmentActivity with tabhost doesn't show the first tab's content Android标签:第二个标签中的内容被隐藏在第一个标签中 - Android Tabs: content from the second tab gets hidden under content from the first tab 无论我们将tab2设置为默认选项卡,android第一个选项卡intent oncreate总是被调用 - android first tab intent oncreate always called regardless we set tab2 as default tab Android-如何将操作栏标签设置为首次选择? - Android - How to set an action bar tab as first selected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM