Firstly I'd like to say that I have only been working on Android for about a week now, so I guess you can consider me a newb! Therefore I apologise in advance if the solution is overly simple, but I can assure you that I have done my research before posting here, and haven't found an appropriate solution as of yet (or maybe I have and don't fully realise it!). Nonetheless, having lots of fun and just want to solve this problem and learn, so here goes...
The Application
The application I am developing is essentially a reminder service, and I am currently working on the preferences screen.
The Problem
I would like the user to be able to specifiy a time when he/she will be reminded daily. I want this selection to be done via the preferences screen. This is how my preferences screen looks so far...
My preferences screen
My Question
Ideally, whenever the user selects the "Alarm Time" preference, I would like the following to appear (this is a screenshot of a preference from another application - PillReminder).
Preference with Time Picker widget (taken from another app - "PillReminder")
My question is, what is the best way to create this? I really want to keep all the visual aspects of the application using only XML, therefore I don't want a Java solution. Is this possible or am I completely off track? Other potential solutions I have heard of are using themes, alert dialogs and extending preference classes etc. Maybe some of these are correct, but I am u开发者_开发百科nsure.
Any help would be greatly appreciated, thanks! :)
My question is, what is the best way to create this?
That is probably a custom DialogPreference
that happens to have a TimePicker
in it.
I really want to keep all the visual aspects of the application using only XML, therefore I don't want a Java solution.
Custom preferences like this cannot be defined in XML. You will need to create a subclass of DialogPreference
, define what goes in the dialog, and how the dialog's contents can be stored to (and retrieved from) a SharedPreference
value.
My ColorMixer CWAC project has a ColorPreference
that you may wish to examine.
精彩评论