0

I have a sentence which is input from the EditText.

I need to display that text in the TextView and provide options for the user to highlight one or more words in TextView.

One approach I thought is to break the input text to multiple TextViews and provide a onclicklistener to highlight. Are there any better ideas or reusable libraries to highlight specific text in TextView dynamically.

  • 1
    you can checkout this one: http://stackoverflow.com/questions/2120035/highlight-text-in-textview-or-webview – AlbertFG Sep 17 '15 at 16:27
  • 1
    please in brief. you are having a text. so in edittext, if you type you need to highlight that? if it is like that, then refer this. http://stackoverflow.com/a/10800276/1921263 – Shadow Sep 17 '15 at 16:27
  • this library might help you https://github.com/lawloretienne/Trestle – Sharjeel Sep 17 '15 at 16:30
  • It is something like If i enter a string in edit text. I need to display a TextView with the edit text entered. The user should be apply to click on the individual string items and get the words selected – Sandesh BS Sep 18 '15 at 19:15

1 Answers1

0

You can use HTML for text color\background\etc changing. For example:

        StringBuilder builder = new StringBuilder();
        builder.append("not_highlighted_word").append(" ");
        builder.append("<font color=#63a34a>").append("highlighted_word").append("</font>");
        textView.setText(Html.fromHtml(builder.toString()));
stfbee
  • 431
  • 5
  • 10