开发者

Select Text In Android

Is it Possible to Dis开发者_开发问答play some text say a story, in an ANDROID app which also enables the user to select some text and perform some operations on that text..

the main idea is to display some text and when the user selects some text(a word or a sentence) i need to get that text for some further operation on that text.

we cant use text view as you cant select text in textview,and we cant use editview because the user should not be able to edit the contents of the text.


Why not display the text in a WebView and enable text selection?

It works pretty well in CodePad, which is open source so you can have a look at the code here.


My first try would be to display this text in a normal TextView. Then I would provide two or three buttons to implement the selection of a part of the text. For example 1 Button to start and end selection and 2 Buttons with arrows for increasing/decreasing the part of the selection.

To highlight the part of the text which is selected, I would for example color this part of the text in a different color.

Coloring of text can be either done by using Spannable or the HTML class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜