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
  •  | 
  •  

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.

有帮助吗?

解决方案

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

if(Double.valueOf(yourText) == 0)
{
     //do something scary
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top