1

I am trying to create a settings page for an app, this app require to have a tab-bar at the bottom. I was able to create a Preference page using the <PreferenceScreen/> and also created a tab using the TabHost. But my problem is that I am not able to figure out how to bring the Tab-bat to the PreferenceScreen page. I am trying to bring something like this :

enter image description here

Thanks in advance

Happy Coding...

rahul
  • 2,758
  • 5
  • 32
  • 53

1 Answers1

1

You can test it with Tab Fragment, here is a Tab Fragment in ActionBar, each one of then must be handle similar to how does FragmentTabs.java does it:

 public void onTabChanged(String tabId) {
            TabInfo newTab = mTabs.get(tabId);
            if (mLastTab != newTab) {
                FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
                if (mLastTab != null) {
                    if (mLastTab.fragment != null) {
                        ft.detach(mLastTab.fragment);
                    }
                }
                if (newTab != null) {
                    if (newTab.fragment == null) {
                        newTab.fragment = Fragment.instantiate(mActivity,
                                newTab.clss.getName(), newTab.args);
                        ft.add(mContainerId, newTab.fragment, newTab.tag);
                    } else {
                        ft.attach(newTab.fragment);
                    }
                }

                mLastTab = newTab;
                ft.commit();
                mActivity.getSupportFragmentManager().executePendingTransactions();
            }
        }

Then you need to change the style for the tabs on the actionbar, you can check the Styling the action bar or the styleActionbar direcly on the reference, i believe that the actionBarTabStyle is the where you should start customizing.

Also don't forget that the Fragment of the preferences must extend from PrefrenceFragment

Community
  • 1
  • 1
Necronet
  • 6,704
  • 9
  • 49
  • 89