Android中对Dialog以及NumberPicker的配置

无简介

目标:弹出一个对话框

客户:给我一个选择时间的对话框吧。 程序猿:好 allThemeError 客户:呵呵

进化①

程序猿:Dialog真难看,设置一下样式吧。

public class SumileNumberPickerDialog extends AlertDialog

首先我自定义了一个类,继承了AlertDialog,然后我们就看到了他的构造方法 sumilegouzaofangfa 程序猿:窝草,这里有设置Theme的地方哎~ 于是,程序猿欢快的写下了下面的代码: sumileDialogSuccess 一运行: d 程序猿:黑了个嘿嘿嘿,dialog好了,里面的numberPicker怎么可以那么丑!

进化②

程序猿:既然Dialog可以设置Theme,那么NumberPicker是不是也可以呢? 呵:

A widget that enables the user to select a number form a predefined range. There are two flavors of this widget and which one is presented to the user depends on the current theme.

If the current theme is derived from android.R.style.Theme the widget presents the current value as an editable input field with an increment button above and a decrement button below. Long pressing the buttons allows for a quick change of the current value. Tapping on the input field allows to type in a desired value.
If the current theme is derived from android.R.style.Theme_Holo or android.R.style.Theme_Holo_Light the widget presents the current value as an editable input field with a lesser value above and a greater value below. Tapping on the lesser or greater value selects it by animating the number axis up or down to make the chosen value current. Flinging up or down allows for multiple increments or decrements of the current value. Long pressing on the lesser and greater values also allows for a quick change of the current value. Tapping on the current value allows to type in a desired value.
For an example of using this widget, see android.widget.TimePicker.

看到没,和系统的主题有关~ 可是,我系统主题是对的啊 sumile_dialog_theme 哎,我记得Activity也可以设置Theme啊,Dialog是依赖于Activity的,那Dialog的样式是不是因为Activity呢? 窝草 sumile_manifest_theme 谁干的!这里加毛Theme。。 去掉之后的效果: allOk

结果

客户:嘿嘿嘿

-------------本文结束  感谢您的阅读-------------
下次一定