Set focus in an empty edittext, how can I implement an Android application

I use one application call. I add checks on the login page, then two fields require a username and password. I apply validations, and then the focus does not receive, and then sets the focus in the empty edittext.

<P →
 if(Username.contentEquals("")) {
    > Toast.makeText(LBS.this, "Please enter
    > username ",Toast.LENGTH_SHORT).show(); 
    > } else { if( pwd.contentEquals("")) 
    > Toast.makeText(LBS.this, "Please enter
    > password ",Toast.LENGTH_SHORT).show();
    > else
    >             try { ........................... }

without filling in the username, and then filling out the password, then the username has entered some toasts displayed in the form of precise focus, entered into the edittext username, this is a problem how you can implement focus in an empty username

+3
source share
1 answer

You should be able to use requestFocus after you return with Toast.

, editText , , username.requestFocus();

, . edittext I, , ( ), , . , / requestFocus.

+19

Source: https://habr.com/ru/post/1742227/


All Articles