2013-04-16 127 views
5

我期待在做Android的一个基本的选择器,看起来像内置的日期和时间选择器,但使用字符串,而不是日期和时间的自定义数组:的Android窗口小部件选择器的任意字符串

enter image description here

http://developer.android.com/guide/topics/ui/controls/pickers.html

这可能是最基本的问题之一,我看到很多自定义的采摘和车轮左右浮动,但我特别希望这具有相同的外观和感觉内置采摘。做这个的最好方式是什么?

编辑:所以我使用TimePicker小部件来显示一个时间选择器,但我可以用什么来从一个任意字符串列表中选择呢?

+0

创建一个自定义对话框,填入相应的UI元素 – Raghunandan

+0

好,这是那种我错过了什么,我应该使用哪个UI元素? – SaltyNuts

回答

7

的外观和感觉来自android.widget.NumberPicker

<NumberPicker 
    android:id="@+id/numberPicker1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
+3

它实际上比这更简单,显然只是使用'String [] values = .....; picker.setDisplayedValues(values);'会做的伎俩,其中'picker'是一个'NumberPicker'。 – SaltyNuts

相关问题