我使用下面的代码在 customEditText(EditText
) 的 end
设置了 cursor
但它没有带来任何效果。
customEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
String customEditTextText = customEditText.getText().toString();
int selection = customEditTextText.length();
customEditText.setSelection(selection);
}
}
});
有人对此有什么想法吗?
最佳答案
我对 AlertDialog 中的 EditText 也有同样的问题。我的解决方案是这样的:
mEditText.post(new Runnable() {
@Override
public void run() {
mEditText.setSelection(mEditText.length());
}
});
关于android - EditText.setSelection(end) 没有效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23719492/