0

I'm making an app that will have three tabs, one of them should have a map fragment.

I created tabs using TabActivity, which is now deprecated. It is recommended to use sliding tabs. My question would be this - can I disable one tab (the one with the map fragment), or is it already disabled for map? Also should I use this code (with TabActivity) or use sliders?

My original code:

    public class MainActivity extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Resources resources = getResources();
    TabHost tabHost = getTabHost();

    // First tab
    Intent intentTabOne = new Intent().setClass(this, TabOneActivity.class);
    TabSpec tabSpecTabOne = tabHost
        .newTabSpec("Tab One")
        .setIndicator("", resources.getDrawable(R.drawable.icon_one_config))
        .setContent(intentTabOne);

    // Second tab
    Intent intentTabTwo = new Intent().setClass(this, TabTwoActivity.class);
    TabSpec tabSpecSecondTab = tabHost
        .newTabSpec("Tab Two")
        .setIndicator("", resources.getDrawable(R.drawable.icon_two_config))
        .setContent(intentTabTwo);

    // Third tab
    Intent intentTabThree = new Intent().setClass(this, TabThree.class);
    TabSpec tabSpecSent = tabHost
        .newTabSpec("Tab Three")
        .setIndicator("", resources.getDrawable(R.drawable.icon_three_invitations_config))
        .setContent(intentTabThree);

    // add all tabs
    tabHost.addTab(tabSpecTabOne);
    tabHost.addTab(tabSpecTabTwo);
    tabHost.addTab(tabSpecTabThree);

        //set Windows tab as default 
        tabHost.setCurrentTab(0);
    }
Banana
  • 2,435
  • 7
  • 34
  • 60

1 Answers1

1

You may want to look into ViewPager since TabActivity has now been deprecated.

Another SO issue using ViewPager suggests that you can disable swiping/sliding on it using a custom ViewPager. You can check out the issue linked.

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17
  • Thank you for your answer, I already did use ViewPager and replaced it with a custom ViewPager in the app_bar_main, and it worked, but I forgot to answer this question :) – Banana Dec 27 '15 at 09:43