-1

Is there a way I can pop a Toast when ever a user types a particular number from the keyboard eg 999 in the android phone. I have made a research regarding this but what am seeing is to make a toast at interval or launch an app on dialing a number. Thanks

Andrea Robinson
  • 225
  • 4
  • 23

2 Answers2

1

This is how you can make a toast , when the user enters a numeric value equal to 999 , this will throw a toast.The toast can be thrown at a button click, the button click method(onButtonClick()).

public void onButtonClick(View View) { 
final EditText numberText= (EditText) findViewById(R.id.numberInputEditBox); 
if (numberText.equals(999)) { 
Toast.makeText(getApplicationContext(), "You Have Entered The Number 999!", Toast.LENGTH_SHORT).show();
   }
}
0

On your edit text add an aftertextchangelistener using addTextChangeListener() method. And if the text input equals "999" you can show your toast message.

Thomas R.
  • 7,988
  • 3
  • 30
  • 39