android中edittext怎么获取光标
1个回答
展开全部
下面是edittext获取光标的例子,更多关于edittext的介绍,请参考android学习手册。
android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,
源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳
int index = editText.getSelectionStart();
int index = editText.getSelectionStart();
2.在光标处插入字符
[java] view plain copy print?
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.insert(index, "aaaa");
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.insert(index, "aaaa");
3.删除光标前字符
[java] view plain copy print?
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.delete(index-1, index);
android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,
源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳
int index = editText.getSelectionStart();
int index = editText.getSelectionStart();
2.在光标处插入字符
[java] view plain copy print?
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.insert(index, "aaaa");
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.insert(index, "aaaa");
3.删除光标前字符
[java] view plain copy print?
int index = editText.getSelectionStart();
Editable editable = editText.getText();
editable.delete(index-1, index);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询