dimanche 17 mars 2019

How to show different Message for different input length in EditText?

I want to show some different message to user for different length of input they make. But my code is not working. What's wrong with that?

EditText boxID = findViewById(R.id.vcInput);
Button button = findViewById(R.id.refresh);
TextView tv = findViewById(R.id.message)

final int inputLength = boxID.getText().toString().length();


if(inputLength >= 10 && inputLength <= 11)
  {tv.setText("Refresh request sent");}

else if(inputLength<1)
       {tv.setText("VC number field looks empty");} //Only this one works at any input length

else if(inputLength>1 && inputLength<10)
       {tv.setText("VC number must be at least 10 digit");}

else {tv.setText("Wrong input");}

Aucun commentaire:

Enregistrer un commentaire