editText field is required before moving on to another Activity

后端 未结 7 1306
情深已故
情深已故 2021-01-30 17:14

I have validation for editText. If the editText field is empty it should fail validation and stop the user moving on to another Activity,

7条回答
  •  心在旅途
    2021-01-30 18:00

    Better to test empty textField using If condition for all required or special validation cases and setError to focus.

    If(txtName.getText().toString().trim().equals(""))
    {
    //Your message or any other validation
    }
    

提交回复
热议问题