开发者

Android FragmentPreference and ViewPager

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.andr开发者_运维问答oid.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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜