开发者

selection in textview

开发者 https://www.devze.com 2023-01-09 01:41 出处:网络
I have a Text View in my application开发者_运维问答 and I want to select text from that text view and i want the starting & ending position of that

I have a Text View in my application开发者_运维问答 and I want to select text from that text view and i want the starting & ending position of that selected text so can anyone please help me.


Starting and Ending position may be retrieved with:

  int selectionStart = textView.getSelectionStart();
    int selectionEnd = textView.getSelectionEnd();

and Selected text may be with:

String selectedText = et.getText().substring(selectionStart, selectionEnd);


I'm not sure there's any way of programmatically making a selection in a TextView.

However, you can get the start and end position of a selection by calling TextView.getSelectionStart(), optionally calling hasSelection() first if you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消