Strange Error using onCreateView in PreferenceFragment when calling addPreferencesFromResource from onCreate

后端 未结 3 458
慢半拍i
慢半拍i 2021-01-03 00:34

I\'m trying to add an ImageView to a preference fragment in order to show a preview of a color setting. I\'m accessing the instance of the imageview via the onCreateView met

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 01:19

    I had this problem today as well. It stemmed from using the Android Tutorials here: http://developer.android.com/guide/topics/ui/settings.html#Fragment

    Basically, I found the problem came from using the preferences.xml file:

    addPreferencesFromResource(R.xml.preferences);
    

    Once I commented this out, the error went away and my activity started showing, although unpopulated by preferences. I'll try to hunt this down and follow up here.

    I hope this helped so far! The exception thrown is not very helpful.

提交回复
热议问题