如何添加两个数字选择器值 [英] How to add two number picker values

查看:74
本文介绍了如何添加两个数字选择器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

btnmale.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus)
            {

                Double ft = Double.valueOf(malepicker1.getValue());
                Double in = Double.valueOf(malepicker2.getValue());
                Double cm;
                cm = (ft * 12 + in) * 2.54;
                Toast toast=Toast.makeText(getApplicationContext(), (int)+cm,Toast.LENGTH_SHORT);
                toast.setMargin(50,50);
                toast.show();

            }
            <pre>});





我尝试了什么:



我有两个号码选择器

malenumberoicker1和malenumberpicker2

i想要计算两个值。当从数字选择器1中选择一个值并从数字选择器2中选择一个值时,应该显示结果吗?

i尝试了但是没有工作的应用程序崩溃?请帮帮忙

代码在上面我正在解决



What I have tried:

I am having two number pickers
malenumberoicker1 and malenumberpicker2
i want to do calculation of two values. when selected one value from number picker 1 and one value from number picker 2. should display result ?
i tried but not working app getting crash ?pls help out
code is above which i work out

推荐答案

您正在将计算总数传递给 makeText 方法,该方法需要一个资源id在该字段中。请参阅 Toast  |  Android开发者 [ ^ ]

您应该首先将值转换为字符串,然后显示内容。
You are passing the total of your calculation to the makeText method which expects a resource id in that field. See Toast  |  Android Developers[^]
You should first convert the value to a string, which will then show the content.


这篇关于如何添加两个数字选择器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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