vishwas vishwas - 5 months ago 11
Android Question

How to compare String from edittext not less than 10 in android?

I have an edit text in which user enters an amount and I want to compare that amount not less than 10, if found less than 10 then I want to show toast message. How can I do that?

m_szAmount = m_InputAmount.getText().toString().trim();
if (m_szAmount.equals(10)) {
m_InputAmount.setError("Please enter the amount between Rs. 10 and Rs. 1100");

} else {
confirmationDialog();
}

Answer

Try to this code :

m_szAmount = m_InputAmount.getText().toString().trim();

if (Integer.valueOf(m_szAmount) == 10){
    m_InputAmount.setError("Please enter the amount between Rs. 10 and Rs. 1100");

} else {
    confirmationDialog();
}
Comments