-1

I want to write a input filter such that if i say the edit text should not have a number higher than 40 you can input 1-40 , but anything else will not work

I do not want to do that with a text watcher, but an InputFilter

how can I do that ?

Lena Bru
  • 13,521
  • 11
  • 61
  • 126

1 Answers1

0

There's a property of EditText (in xml) called:

android:inputType="number"    

You might be having a button click or something during which you would validate the EditText, there you can do something like this:

int num = Integer.parseInt(editText.getText().toString());
if(num<1 || num>40)
{
  // display a message that you have to write something to EditText first
}
Sarthak Mittal
  • 5,794
  • 2
  • 24
  • 44