Is it possible to launch a DialogFragment from a Preference in a PreferenceActivity?
-
15-02-2021 - |
質問
I am converting my app to use the v4 compatibility package and fragments. I have done well so far, but I need to launch a DialogFragment from a preference click in a PreferenceActivity
. Since there isn't a PreferenceFragment in the compatibility library, I'm stuck with using PreferenceActivity
. Is it possible to get a reference to the fragment manager and call the DialogFragment
or do I just have to continue using the old dialog if I need a dialog from a preference?
解決
Not without jumping through hoops.
You could make a very simple activity with the sole purpose of launching the DialogFragment. If you do this you will need to finish() that activity when the DialogFragment dialog has been dismissed.
所属していません StackOverflow