Check if edittext is empty
Approach 1:
EditText txtUserName = (EditText) findViewById(R.id.txtUsername);
String strUserName = usernameEditText.getText().toString();
if (strUserName.trim().equals("")) {
Toast.makeText(this, "plz enter your name ", Toast.LENGTH_SHORT).show();
return;
}
Approach 2:
You can use length() from EditText.
public boolean isEditTextEmpty(EditText mInput){
if(mInput.length() == 0)
return true;
else
return false;
}
Comments
Post a Comment