How can I set the focus to a button but without setting setFocusableInTouchMode to true?
I first tried this:
button.requestFocus();
That simply does not work. I then tried this:
button.setFocusableInTouchMode(true);
button.requestFocus();
The problem is, it highlights the button. I don't want the button to be highlighted in touch mode. I simply want the button to be selected when the user hits the enter key or tab key.
To clarify, I simply want the first button to start with focus when not in touch mode.
I guess, you want to this:
button.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_ENTER:
// HIT THE ENTER KEY
break;
case KeyEvent.KEYCODE_TAB:
// HIT THE TAB KEY
break;
}
return false;
}
});
if you don't want to this, could you be clear ? Sorry for my English.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With