-1

I'm trying to implement color highlighting for specific words in a ListView.

I saw another post here suggesting to embed HTML within the text, as follows:

<font color='#FF0000'>Sample text</font>

However, this isn't working, and is instead showing up literally (as opposed to the tags taking effect and coloring the text).

I'm assuming there might be some flag I could toggle on that would allow embedded tags, but I have no idea where to start looking, or if this is even the right way to go about color-coding my listview text.

More information:

  • Listview in question is a simple 1 item per line listview.
  • Listview is populated with data from an array of strings.

My adapter is as follows:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(
        this,
        android.R.layout.simple_list_item_1, 
        android.R.id.text1, 
        screenCode);

Any help would be very much appreciated.

Thanks in advance!

Pratik
  • 1,531
  • 3
  • 25
  • 57
Oxirane
  • 23
  • 3

1 Answers1

0

To geht full control over the generated view per item you could override the method ArrayAdapter.getView. There you could for example build a TextView which renders the html-formatted Text.

Another solution would be to define your own layout. For details see this question: ArrayAdapter in android to create simple listview

Community
  • 1
  • 1
DaniEll
  • 1,022
  • 4
  • 22
  • 31