17

I have defined dialogfragments (because Android documentation says that it is better and indeed it is) but now I want to use it in PreferenceActivity.

The problem is that I cannot use getSupportFragmentManager() there and I cannot use PreferenceFragment since it doesn't work with compatibility library. Looks like a road block scenario.

Can anyone advise on this?

Venki
  • 1,419
  • 5
  • 28
  • 38
Matroska
  • 6,885
  • 14
  • 63
  • 99
  • I've never done this, but maybe you can use a PreferenceFragment instead of a FragmentActivity? http://developer.android.com/reference/android/preference/PreferenceFragment.html – dmon Apr 14 '12 at 03:39
  • 1
    I cannot use PreferenceFragment since it is not available in compatibility library – Matroska Apr 14 '12 at 06:44
  • I've also spent some time on this. The PreferenceActivity.onPrepareDialog() states that the DialogFragment should be available with the compatibility package. But I think that is a mistake. There is simply no FragmentManager available with the PreferenceActivity. – jsmith Apr 23 '12 at 13:22

1 Answers1

1

As you noted, PreferenceFragment is not in the android compatibility package and unfortunately there is no clean way around this. For my own personal project, I had to adapt an implementation off of Android's source code: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.4_r1.2/android/preference/PreferenceFragment.java

The answers to this question have some great suggestions: Was PreferenceFragment intentionally excluded from the compatibility package?

Community
  • 1
  • 1
almalkawi
  • 1,108
  • 1
  • 11
  • 17