How to create a negative NumberPicker

前端 未结 4 794
花落未央
花落未央 2020-12-11 03:35

Does anyone know of an easy way to allow negative numbers with Android\'s default numberpicker? I understand that it\'s the InputFilter that disallows this, but is there an

4条回答
  •  孤街浪徒
    2020-12-11 04:14

    Use:

    
    String[] nums {"-1","-2","-3","-4"};
    numberpicker.setDisplayedValues(nums);
    
    or

    String[] nums = new String[4];
    for(int i=0; i

    Either of those will let you use any set of Strings for your NumberPicker. What you are doing is you are specifying a set of strings which you the pass to the NumberPicker. Then it will display your values instead of the default ones.

提交回复
热议问题