关闭

android EditText获取光标位置

别叨叨 1年前 ⋅ 319 阅读
int index = editText.getSelectionStart();

1、在光标处插入字符:

int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.insert(index, "xyz");

2、删除光标前字符:

int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.delete(index-1, index);

全部评论: 0

    我有话说: