I don't know how to make a correct IF that filters if the content of an EditText is different from zero

StackOverflow https://stackoverflow.com/questions/20438510

  •  30-08-2022
  •  | 
  •  

Question

How to avoid 0 and 0.0 and 0.00 and 0.000 and 0.0000 e all the other "zeros" the user can type. If were for only one, I know how to do with string comparison, but I have this problem with several strings, but only one meaning.

Was it helpful?

Solution

Try to parse your string into double and compare it to 0:

if(Double.valueOf(yourText) == 0)
{
     //do something scary
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top