Using NumberPicker in Android 3

不想你离开。 提交于 2019-12-20 03:16:29

问题


I'm trying to use the NumberPicker widget in Android 3.1. I figure it is now a standard widget, part of a public API, and not an internal widget anymore. However, it doesn't work. I can see a textEdit with "0" in it, but there are no buttons, I can't scroll it, and I can't enter a new number with keyboard, either.

Update:

Here's the xml I used for testing:

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

</LinearLayout>

By saying doesn't work I mean this: it doesn't have arrows displayed (see the screenshot), and on emulator the keyboard doesn't show up. On a real device it does, but I can't type in the text, I can only erase it.

Any suggestions? I really hate to write my own widget when there is a standard one.


回答1:


Try to set the values that are possible in the NumberPicker via

setMaxValue setMinValue or setDisplayedValues

maybe the NumberPicker is not working if it doesn't know which values to display.



来源:https://stackoverflow.com/questions/7979857/using-numberpicker-in-android-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!