int selectionStart = textView.getSelectionStart();
int selectionEnd = textView.getSelectionEnd();
String selectedText = et.getText().substring(selectionStart, selectionEnd);
不过最好经过hasSelection() 判断一下
本文介绍了一种在Android环境下通过TextView组件获取用户所选中文本的起始与结束位置的方法,并建议先使用hasSelection()方法判断当前是否已选择文本。
int selectionStart = textView.getSelectionStart();
int selectionEnd = textView.getSelectionEnd();
String selectedText = et.getText().substring(selectionStart, selectionEnd);
不过最好经过hasSelection() 判断一下
813
1263

被折叠的 条评论
为什么被折叠?