Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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>});


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
Posted
Updated 31-Aug-18 6:52am
Comments
David Crow 31-Aug-18 23:07pm    
"i tried but not working app getting crash ?pls help out"

What exactly does "crash" mean in this context? Should you be surrounding your code in a try/catch block? Should you be checking return values from functions? What about stepping through the code using the debugger?

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900