The User can enter only one digit in the edit text. if he enters the value in edtText1, I want the cursor automatically moves to edtText2 and so on. The user can able to edit the text which he/she has entered already. I tried the following way.
edtPasscode1.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode1.getText().length() == 1)
edtPasscode2.requestFocus();
return false;
}
});
edtPasscode2.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode2.getText().length() == 1)
edtPasscode3.requestFocus();
return false;
}
});
edtPasscode3.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode3.getText().length() == 1)
edtPasscode4.requestFocus();
return false;
}
});
If the user edit the text, The cursor moves to some other editTexts and not working as desired. How can i achieve the above?