简体   繁体   中英

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:

    minutePicker.setMaxValue(10);
    minutePicker.setMinValue(1);
    minutePicker.setDisplayedValues(values);

provided values is {"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

Create NumberPicker class like below

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));
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM