Setselection In Edittext's Onfocuschange
Normally, when the view is clicked, the text cursor is set near the place you clicked on. I try to set it always to the end (past the last character), but it does nothing unless th
Solution 1:
No need delay. we need to wait setSelection
or else automatically called done and execute my setSelection
.
newOnFocusChangeListener() {
@OverridepublicvoidonFocusChange(View v, boolean hasFocus) {
if(hasFocus) {
finalEditTextet= (EditText) v;
et.post(newRunnable() {
@Overridepublicvoidrun() {
et.setSelection(et.getText().length());
}
});
}
}
});
Solution 2:
You should call setSelection()
inside the afterTextChanged()
of the addTextChangedListener()
.
Post a Comment for "Setselection In Edittext's Onfocuschange"