Display error if user enters only spaces in EditText - Android
for me i use trim.Trim will remove first and last space of a string entered by a user.
String tName = tName.getText().toString.trim();
if(tName.matches("")){
Toast.makeText(MainActivity.this, "Must Add Your Name Here", Toast.LENGTH_SHORT).show();
}
Try with this code
if(!editText.getText().toString().trim().isEmpty()){
editText.setError("Empty spaces are not allowed");
editText.setFocusable(true);
Toast.makeText(MainActivity.this, "Must Add Your Name Here", Toast.LENGTH_SHORT).show();
}