如何获得从选定文本的EditText android系统中?如何获得、文本、系统、EditText

2023-09-05 03:43:10 作者:青冢

我有一些文字被选择的EditText。我想从EditText上的点击按钮的选定文本。

请建议我使用的链接或样品code。

解决方案

 的EditText等=(EditText上)findViewById(R.id.edit);

INT startSelection = et.getSelectionStart();
INT endSelection = et.getSelectionEnd();

字符串selectedText = et.getText()的toString()子(startSelection,endSelection)。
 

Android修改6.0系统文本选择菜单

I have a edittext in which some text are selected . I want to get only selected text from edittext on click of button .

Please suggest me usable link or sample code.

解决方案

EditText et=(EditText)findViewById(R.id.edit);

int startSelection=et.getSelectionStart();
int endSelection=et.getSelectionEnd();

String selectedText = et.getText().toString().substring(startSelection, endSelection);