3

首先我想说我现在只在Android上工作了大约一个星期,所以我想你可以认为我是新手!因此,如果解决方案过于简单,我提前道歉,但我可以向您保证,我在发布之前已经完成了我的研究,并且还没有找到合适的解决方案(或者我可能已经并且没有完全意识到它!)。尽管如此,有很多乐趣,只是想解决这个问题并学习,所以这里......

应用程序

我正在开发的应用程序本质上是一个提醒服务,我目前正在使用首选项屏幕。

问题

我希望用户能够指定每天提醒他/她的时间。我希望通过首选项屏幕完成此选择。到目前为止,这就是我的首选项屏幕的外观...

我的偏好屏幕

我的问题

理想情况下,每当用户选择“闹钟时间”首选项时,我希望出现以下内容(这是来自另一个应用程序的首选项的屏幕截图 - PillReminder)。

时间选择器小部件的偏好(取自另一个应用程序 - “PillReminder”)

我的问题是,创建它的最佳方法是什么?我真的想只使用 XML来保留应用程序的所有视觉方面,因此我不想要 Java 解决方案。这是可能的还是我完全偏离了轨道?我听说过的其他潜在解决方案是使用主题、警报对话框和扩展偏好类等。也许其中一些是正确的,但我不确定。

任何帮助将不胜感激,谢谢!:)

4

1 回答 1

2

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.

于 2011-02-19T14:43:06.800 回答