3

I am implementing one application gust i am adding validations in login page implemented then two fields required username and password button login i am applying validations then focus are not getting then set focus in unfilled edittext

>

 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 { ........................... }

not filling username then filling password then username entered some toast displayed fine focus are entered in username edittext this is the problem how can implemented focus in unfilled username

1 Answer 1

19

You should be able to use requestFocus after you've come back from the Toast.

For example, if you've got an editText object called username, you SHOULD be able to add a line like username.requestFocus();

But I'm having some problem, right now, making that work just right. In my emulator, the edittext I specify appears to have focus (blinking cursor) but the next field also has a blinking cursor and is where the next key strokes go. So there may need to be some extra bit of code before/after the requestFocus call.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.