android numberpicker for floating point numbers

前端 未结 3 1296
情书的邮戳
情书的邮戳 2021-02-06 05:22

The user of our app should be able to adjust a floating point number. At the moment, I filled an ArrayAdapter with all possible values and attached it to a spinner.

This

3条回答
  •  野的像风
    2021-02-06 05:34

    NumberPicker is not just for integers.. Even you can use Floats String etc.

    see this and read about it.

    for tutorials :

    • http://gafurbabu.wordpress.com/2012/03/29/android-number-picker-dialog/

    And I had used NumberPicker long ago like this and it might be some use posting here:

        NumberPicker np;
        String nums[]= {"Select Fraction","1/64","1/32","3/64","1/16","5/64","3/32","7/64","1/8","9/64","5/32","11/64","3/16","13/64","7/32","15/64","1/4","17/64","9/32","19/64","5/16","21/64","11/32","23/64","3/8","25/64","13/32","27/64","7/16","29/64"};
    
                np = (NumberPicker) findViewById(R.id.np);
    
                np.setMaxValue(nums.length-1);
                np.setMinValue(0);
                np.setWrapSelectorWheel(false);
                np.setDisplayedValues(nums);
                np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); 
    

    You can make ArrayList of any datatype and assign it.

提交回复
热议问题