I want to have a custom dialog (created using layout) in Preferences. What should I do to declare this custom dialog in my preferences?
Asked
Active
Viewed 2.1k times
8
CopsOnRoad
- 175,842
- 51
- 533
- 380
Eugene
- 57,641
- 91
- 219
- 328
1 Answers
6
Implement a DialogPreference for your custom layout and add that preference to your preference screen
Here is a good explanation of how to do this: Concise way of writing new DialogPreference classes?
Community
- 1
- 1
Christopher Souvey
- 2,880
- 19
- 21
-
Cool. Do you know how to hook this new class to SharedPreferences themselves? – Eugene Sep 17 '11 at 18:09
-
The StackOverflow answer I linked explains how to persist data using either helper methods or SharedPreferences – Christopher Souvey Sep 17 '11 at 18:12
-
Sorry, there is no a single work how to refer to the new class from your xml where you declare preference items. – Eugene Sep 17 '11 at 18:17
-
1In the XML, you must use the full name (including package) of your class that extends DialogPreference. See sample XML here: http://stackoverflow.com/questions/5516022/android-launch-a-custom-preference-from-a-preferenceactivity – Christopher Souvey Sep 17 '11 at 18:27