0

Hi i have set up a view pager and fragments for each page and that's all working as it should however i can not get a preference screen to show on one of my pages no matter what i try.

My fragment that i'm trying to add a preference screen looks like this

public class Extras extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View V = inflater.inflate(R.layout.extras, null, false);
        return V;
    }
}

So then i read the documentation on PreferenceFragments here http://developer.android.com/reference/android/preference/PreferenceFragment.html

But when i add this in my Extras class as the above link shows

public static class Extras extends PreferenceFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }
}

I error out just extending PreferenceFragment errors in my view pager i read the below link though that PreferenceFragments aren't part of the compatiblity library which i believe is my issue. So is it possible to add a preference screen in one of my pages in my viewpager or is this something i'm going to have to do with a listview and basically make my own preference screen

Was PreferenceFragment intentionally excluded from the compatibility package?

Thank you for any help with this issue

Community
  • 1
  • 1
user577732
  • 3,956
  • 11
  • 55
  • 76

2 Answers2

1

Never got the answer i was looking for so i ended up going with a listview instead

user577732
  • 3,956
  • 11
  • 55
  • 76
  • my final solution can be found here http://stackoverflow.com/questions/7772679/android-list-in-fragment-for-viewpager – user577732 Oct 15 '11 at 15:59
0

I posted my solution here http://forum.xda-developers.com/showthread.php?t=1363906 I simply rebuilt the hidden Preference* class via Reflection.

user765269
  • 311
  • 1
  • 4
  • 12