Question

I am developing a application in which i am using Tab host without fragment. I want to remove action bar in particular Tab2Activity(Tab1 Tab2 Tab3).

Was it helpful?

Solution

The Tabs start from 0 and goes 0, 1, 2, 3...

If you're selecting Tab 1 use Tab 0.

    @Override
public void onTabSelected(ActionBar.Tab tab,
        FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, switch to the corresponding page in
    // the ViewPager.
    mViewPager.setCurrentItem(tab.getPosition());

    if (tab.getPosition() == 0) {
        Toast tab1SelectedToast = Toast.makeText(this, "Tab 1 Selected", Toast.LENGTH_LONG);
        tab1SelectedToast.show();
        ActionBar actionBar = getActionBar();
        actionBar.hide();

    } else {
        ActionBar actionBar = getActionBar();
        actionBar.show();
    }
}

OTHER TIPS

Make the activity listen to tab changed, when changed ask tab if you should hide the action bar by adding a method and some interface, if the current tab returns true, hide the action bar, else show it.

try this..

getTabHost().setOnTabChangedListener(new OnTabChangeListener() {

            @Override
            public void onTabChanged(String tabId) {

                int i = getTabHost().getCurrentTab();
                Log.i("@@@@@@@@ ANN CLICK TAB NUMBER", "------" + i);

                if (i == 0) {
                    Log.i("@@@@@@@@@@ Inside onClick tab 0", "onClick tab");



                } else if (i == 1) {
                    Log.i("@@@@@@@@@@ Inside onClick tab 1", "onClick tab");


                }

            }
        });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top