i have 2 edit Text in my application, 1 button to add the input numbers in the edit Text and 1 text view to display the result. I would like to put a toast message if my edit te
To create and show a Toast use this code:
Toast.makeText(this, "Please input number", Toast.LENGTH_LONG).show();
In order to work properly, you should replace this code:
if (editText1.equals("")) {
editText1.setError("please input number");
}
if (editText2.equals("")) {
editText2.setError("please input number");
}
with this:
if (editText1.getText().toString().length() == 0 || editText1.getText().toString().length() == 1) {
Toast.makeText(this, "Please input number", Toast.LENGTH_LONG).show();
}