I'm trying to implement custom DialogPreference
, whose layout will use fragments. An app should support API 10
(which does not natively support fragments).
In order to work with fragments I need to get an instance of the android.support.v4.FragmentManager
(normally usually being received from support FragmentActivity using getSupportFragmentManager
).
I have no idea how to get android.support.v4.FragmentManager
within DialogPreference. Any clue is appreciated.
If you are calling the dialog from an android.support.v4.app.FragmentActivity
you should be able to do a type cast in your DialogPreference
class, to get the Support-FragmentManager:
(android.support.v4.app.FragmentActivity)getContext()).getSupportFragmentManager()
... if that's not possible, another solution would be to launch an activity that looks like a dialog , and use your fragments there. How to open an activity from a PreferenceScreen?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.