Good day. There is a html-text displayed in the ListView . listView does not accept html tags and displays the text as is. Can you please tell me how to make the listView display text with the tags? Thank.

I found this solution in the Internet:

 ArrayAdapter<String> adapter= ArrayAdapter<String>(SearchByFood.this, R.layout.new_list_view, arr_sort){ public Object getItem(int position) { return Html.fromHtml(arr_sort.get(position)); } }; 

But then I have an Object underscore and in the error log:

 Error:(47, 27) error: getItem(int) cannot override getItem(int) in ArrayAdapter return type Object is not compatible with String where T is a type-variable: T extends Object declared in class ArrayAdapter 
  • There is a WebView for displaying HTML . ListView This is not intended. - Vladyslav Matviienko

1 answer 1

You can display HTML in TextView like this:

 textView.setText(Html.fromHtml("text <b>bold text</b> more text")); 

The list of supported tags can be found here .

How to make support for other tags, see here.