Preference Screen in SlidingTabLayout

212 views Asked by At

I am currently using the example from Google's slidingtablayout in my code.

I would like to replace one of the tabs' layout as a preference screen instead of the current linear/relative layout.

How can I do this?

1

There are 1 answers

1
Anton Kovalyov On BEST ANSWER

Just add item PreferenceFragment to your ViewPager adapter.

public static class PrefsFragment extends PreferenceFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.preferences);
    }
}

ViewPagerAdapter:

@Override
        public Fragment getItem(int position) {
            switch (position) {
            case 0:
                return new PrefsFragment();
            default:
                return null;
            }
        }