gpt4 book ai didi

android - android API 11 中的空 NumberPicker

转载 作者:行者123 更新时间:2023-11-29 22:01:28 24 4
gpt4 key购买 nike

我创建了 NumberPicker,但它是空的,我无法单击文本字段以外的任何内容,这是“0”,当我这样做时,键盘会弹出。这是一张图片来阐明我的意思。

图片: enter image description here

这是我用来创建对话框的代码:

Dialog dialog = new Dialog(SettingsActivity.this);
dialog.setContentView(R.layout.draws_dialog);
dialog.show();

SettingsActivity 是我创建和显示此对话框的 Activity 。

这是我的对话框的 xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<NumberPicker
android:id="@+id/numberPicker1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />

</RelativeLayout>

所以知道我在这里做错了什么吗?

最佳答案

您应该为您的 NumberPicker 设置最小值和最大值,例如:

int minValue = 5;
int maxValue = 20;
int currentValue = 10;

final NumberPicker uiCapacity = findViewById(R.id.capacity);
uiCapacity.setMinValue(minValue);
uiCapacity.setMaxValue(maxValue);
uiCapacity.setValue(currentValue);

关于android - android API 11 中的空 NumberPicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11802892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com