Merge "Move the cursor to the end of the text in edit text." into main

This commit is contained in:
Anushree Ganjam
2023-11-15 22:57:26 +00:00
committed by Android (Google) Code Review

View File

@@ -162,6 +162,15 @@ public class ExtendedEditText extends EditText {
}
}
@Override
public void setText(CharSequence text, BufferType type) {
super.setText(text, type);
// With hardware keyboard, there is a possibility that the user types before edit
// text is visible during the transition.
// So move the cursor to the end of the text.
setSelection(getText().length());
}
/**
* This method should be preferred to {@link #setOnFocusChangeListener(OnFocusChangeListener)},
* as it allows for multiple listeners from different sources.