I want to move cursor from EditText1 to another EditText2 . I had already focused to editText1 but how to move cursor to editText2.?
Say in your xml's edittext section, add android:paddingLeft="100dp" This will move your start position of cursor 100dp right from left end. Same way, you can use android:paddingRight="100dp" This will move your end position of cursor 100dp left from right end.
Finaly i got the answer:
editText1.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = editText1.getText().length();
if (textlength1 >= 1) {
editText2.requestFocus();
}
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
editText2.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength2 = editText1.getText().length();
if (textlength2 >= 1) {
editText3.requestFocus();
}
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
I can understand your answer,
But there is another good way to do it simply by using the following attribute
android:imeOptions="actionNext"
The example :
<EditText
android:hint="@string/hint_user_name"
android:id="@+id/et_user_name"
android:maxLines="2"
style="@style/EditText_Login"
android:imeOptions="actionNext"
/>
Thanks,
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