android numberpicker浮点数 [英] android numberpicker for floating point numbers

查看:75
本文介绍了android numberpicker浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们应用程序的用户应该能够调整浮点数.此刻,我用所有可能的值填充了ArrayAdapter并将其附加到微调器.

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.

由于微调框下拉框太高,此解决方案无法真正满足我们的期望.有没有更好的办法?我当时在看Numberpicker-但这似乎仅适用于Integer值.

This solution doesn't really meet our expectations, since the spinner dropdown box is way too tall. Is there a better way? I was looking at Numberpicker - but this seems to work only with Integer values.

有什么想法吗?

谢谢!

推荐答案

NumberPicker 不仅仅用于整数.即使您可以使用 Floats String 等.

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

请参见并阅读有关内容.

see this and read about it.

关于教程:

我很早以前就这样使用过 NumberPicker ,在这里发布它可能有些用处:

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

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

You can make ArrayList of any datatype and assign it.

这篇关于android numberpicker浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆