[英]Android :: Custom Dialog with number scrollable picker?
PROBLEM 问题
What we call this component in the red circle ?? 我们在红圈中称之为这个组件?
and how can I make dialog that have it on like this. 以及如何制作像这样的对话框。
actually I don't know what its called so I don't know keyword 实际上我不知道它叫什么所以我不知道关键字
to search about that. 搜索一下。 I'm sorry if it feel like weird question.
如果它感觉像是一个奇怪的问题,我很抱歉。
NOTE 注意
I know how to create simple dialog in android anyway 我知道如何在android中创建简单的对话框
Imagine you want to have a NumberPicker
that displays degree values from 0C to 20C. 想象一下,你想要一个显示从0C到20C的度数值的
NumberPicker
。
You have to set a String array to populate your NumberPicker. 您必须设置一个String数组来填充NumberPicker。
First, initialize your String [] with your values, like this: 首先,使用您的值初始化String [],如下所示:
String [] degreesValues = new String [20];
for(int i= 0;i<20;i++){
degreesValues[i] = String.valueOf(i)+ (char) 0x00B0;
}
Then, just apply that array on your NumberPicker
, like this: 然后,只需在
NumberPicker
上应用该数组,如下所示:
NumberPicker picker = (NumberPicker) findViewById(R.id.numberPicker);
picker.setMinValue(0);
picker.setMaxValue(19);
picker.setDisplayedValues(degreesValues);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.