0

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?

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);
}
}
Sammys
  • 1,443
  • 5
  • 14
  • 21

1 Answers1

0

As per android api documentation of FragmentTabHost, add the tab when the argue is not null and use setup method

aorlando
  • 668
  • 5
  • 21