Android Softkey's Next Button Not Taking Focus To Spinner
We have spinner between two text boxes in my Android screen. When the focus is on 1st text box and I am clicking next from softkey, it is directly moving to next textbox instead of
Solution 1:
Use this way:
firsttextbox.setNextFocusDownId(R.id.edtemail);
spinner.setNextFocusDownId(R.id.sp1);
secondtextbox.setNextFocusDownId(R.id.stc);
firsttextbox.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on Enter key press
firsttextbox.clearFocus();
spinner.requestFocus();
return true;
}
return false;
}
});
spinner.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on Enter key press
spinner.clearFocus();
secondtextbox.requestFocus();
return true;
}
return false;
}
});
Post a Comment for "Android Softkey's Next Button Not Taking Focus To Spinner"