use*_*692 12 layout android numberpicker
我在我的布局中添加了NumberPicker并调试了我的应用程序.现在我看到NumberPicker不起作用,我看不到任何"+"或" - "按钮,当我点击键盘上的数字时,没有任何反应.
这是我的布局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#99cc00"
tools:context=".Gewichtsentwicklung" >
<NumberPicker
android:id="@+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp" />
<TextView
android:id="@+id/tvGewichtUeberschrift"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:textSize="13pt"
android:layout_alignParentTop="true"
android:text="Aktuelles Gewicht eingeben" />
<Button
android:id="@+id/btGewicht"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/numberPicker1"
android:layout_marginTop="79dp"
android:text="Gewicht speichern" />
Run Code Online (Sandbox Code Playgroud)
哪个问题?
Mar*_*res 34
您是否实际使用值填充数字选择器?如下所示?
NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker1);
String[] nums = new String[20];
for(int i=0; i<nums.length; i++)
nums[i] = Integer.toString(i);
np.setMinValue(1);
np.setMaxValue(20);
np.setWrapSelectorWheel(false);
np.setDisplayedValues(nums);
np.setValue(1);
Run Code Online (Sandbox Code Playgroud)
数字选择器没有+或-更多地认为它是一个滚轮。您必须设置最小数量和最大数量才能真正显示任何内容
setMinValue(5);
setMaxValue(120);
Run Code Online (Sandbox Code Playgroud)
如果您单击选择器的顶部,它会增加数字,如果您单击选择器的底部,它会减少数字
| 归档时间: |
|
| 查看次数: |
10024 次 |
| 最近记录: |