簡體   English   中英

Android:如何將偏移量設置為10的數字選擇器的最大值設置為最小值

[英]Android: How to set max to min values of numberpicker with offset of 10

當我這樣做時,我想使用值為10、20、30、40、50的數字選擇器:

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

提供的值為{“ 30”,“ 40”,“ 50”,“ 60”,“ 70”};

我無法按預期顯示值,但是就像編輯文本一樣,當我點擊每個值鍵盤顯示時,如何使其僅將值顯示為textview而不是編輯文本

創建如下的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM