Moeez
Moeez

Reputation: 478

How to disable/remove a tab from tabbed activity from android studio?

I am a newbie to native android development. I made an app in android studio using tabbed activity. By default there are 3 tabs in it but i want to remove/disable the third tab. What should i do? I searched many article on it but all i find is for tabhost.

Any help would be highly appreciated

Upvotes: 0

Views: 630

Answers (1)

yadunath.narayanan
yadunath.narayanan

Reputation: 285

In FragmentPagerAdapter inside tabbed activity, change get count return to 2.

 @Override
    public int getCount() {
        // Show 2 total pages.
        return 2;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return "SECTION 1";
            case 1:
                return "SECTION 2";

        }
        return null;
    }

Upvotes: 2

Related Questions