I looked around for other questions but couldn't find one.
if I have an edit text and I enter a number how can I extract those numbers whether its a double/integer... (I have two edit texts called num1 and num2)
when I try and try to extract and check with java it isn't working.
I'm using toasts to check what happens. I will include some snapshots of what I have tried
Toast.makeText(this, "num1 is: "+parseDouble(String.valueOf(num1)) + "num2 is: "+parseDouble(String.valueOf(num1)) , Toast.LENGTH_SHORT).show();
here the program just crashes and doesn't work.
when I try:
Toast.makeText(this, "num1 is: "+(String.valueOf(num1)) + "num2 is: "+(String.valueOf(num1)) , Toast.LENGTH_SHORT).show();
this is my result on num1 and num2 from the edittext:
and when I try
Toast.makeText(this, "num1 is: "+num1 + "num2 is: "+num1 , Toast.LENGTH_SHORT).show();
I get the following:
to make it more clear here is how I input the numbers:
then enter the two numbers:
after I press the calculate sum button I get the toasts that I showed above, I did each one separately.
how can I extract num1 and num2 properly?(do i need to do a split on it with regex or is there a better way to do) let me know what options there are!
the problem isn't that it crashes, its why it doesn't extract the numbers properly like if I enter 2 into the edit text which the id is called num1 then num1 in the java( i have findviewid) should be 2...