Niraj Niraj -3 years ago 132
Android Question

How to make condtiion if string not equal to null and greater than equal to 10 and less than equal to 1000?

I have an app which contain edit text in which user enter amount and i have to make condition if amount not equal to null and must be greater than equal to 10 and less that equals to 1000. But i am getting error.


if (!hasFocus) {
if (m_szAmount.length()==0 && Integer.parseInt(m_szAmount) < 10 && Integer.parseInt(m_szAmount) > 1000) {
} else {

Caused by: java.lang.NumberFormatException: Invalid int: ""

Answer Source

Change your if statement. Your question says you want to check condition 1 and 2 and 3 but you have done is OR(||)

if ((m_szAmount.length()!=0 && Integer.parseInt(m_szAmount)>=10 && Integer.parseInt(m_szAmount)<=1000) && (m_operatorSpinner.getSelectedItemPosition() > 0 && m_circleSpinner.getSelectedItemPosition() > 0)) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download