浮点数的android numberpicker

前端之家收集整理的这篇文章主要介绍了浮点数的android numberpicker前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们的应用程序的用户应该能够调整浮点数.目前,我在ArrayAdapter中填充了所有可能的值并将其附加到微调器上.

这个解决方案并不能满足我们的期望,因为旋转器下拉框太高了.有没有更好的办法?我在看Numberpicker – 但这似乎只适用于Integer值.

有任何想法吗?

谢谢!

解决方法

NumberPicker不只是用于整数..甚至你可以使用Floats String等.

this并了解它.

用于教程:

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

我很久以前就像这样使用了NumberPicker,它可能会在这里发布:

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

您可以创建任何数据类型的ArrayList并分配它.

原文链接:https://www.f2er.com/android/317177.html

猜你在找的Android相关文章