0

I have a password input dialog in the Android fragment. When using the soft keyboard, if a password is wrong a dialog will still show and focus will stay in the editText input box.

The problem is, when a user uses physical keyboards and the password is not right, the focus will be on the cancel button (I have two buttons in the dialog, cancel is on the left and OK is on the right). How can I set the focus on the editText? I've tried to use the requestFocus() function, but it does not work.

Lutaaya Huzaifah Idris
  • 3,596
  • 8
  • 38
  • 77
newszer
  • 440
  • 1
  • 4
  • 23
  • try `editText.requestFocus()` – Junaid Hafeez Jan 24 '17 at 13:51
  • see my edit content, sorry it does not work – newszer Jan 24 '17 at 13:53
  • I add it in another place it worked but the cancel button still shown selected status for a very short time, I have no idea that how can I find the default focus set, it looks like it focus on the cancel button first and then focus on the edittext. – newszer Jan 24 '17 at 13:59
  • Have you tried http://stackoverflow.com/questions/2743559/set-initial-focus-in-an-android-application – Isaac Jan 24 '17 at 14:22

0 Answers0