[英]Android: How to set max to min values of numberpicker with offset of 10
I want to have number picker with values 10,20,30,40,50 when I'm doing like this: 当我这样做时,我想使用值为10、20、30、40、50的数字选择器:
minutePicker.setMaxValue(10);
minutePicker.setMinValue(1);
minutePicker.setDisplayedValues(values);
provided values is {"30", "40", "50", "60", "70"}; 提供的值为{“ 30”,“ 40”,“ 50”,“ 60”,“ 70”};
Im able to display values as expected but these are like edit text, when I'm taping on each value keyboard displays, how can I make it just display value as textview rather edit text 我无法按预期显示值,但是就像编辑文本一样,当我点击每个值键盘显示时,如何使其仅将值显示为textview而不是编辑文本
Create NumberPicker class like below 创建如下的NumberPicker类
public class MyNumberPicker extends NumberPicker {
public MyNumberPicker(Context context, AttributeSet attrs) {
super(context, attrs);
processAttributeSet(attrs);
}
public MyNumberPicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
processAttributeSet(attrs);
}
private void processAttributeSet(AttributeSet attrs) {
//This method reads the parameters given in the xml file and sets the properties according to it
this.setMinValue(attrs.getAttributeIntValue(null, "min", 0));
this.setMaxValue(attrs.getAttributeIntValue(null, "max", 0));
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.