1.获取到光标所在的位置
int index = editText.getSelectionStart();
2.在光标的地方插入字符
int index = editText.getSelectionStart(); Editable editable = editText.getText(); editable.insert(index, "哈哈哈");
3.删除光标前的字符(光标在哪里从哪里开始删除)
int index = editText.getSelectionStart(); Editable editable = editText.getText(); editable.delete(index-1, index);
时间: 2024-10-12 15:03:13