3

this works in onCreate of the activity

String htmlstring="<p><em><strong>hello world</strong></em></p>";

    tv.setText(Html.fromHtml(html));

But when i used the same from a server in a listview its not working

ViewHolder holder = new ViewHolder();

            holder.quest = (TextView) vi.findViewById(R.id.question_data);

            holder.quest.setText(Html.fromHtml(htmlstring));

What is wrong! how can i achieve this?

George Thomas
  • 4,566
  • 5
  • 30
  • 65

1 Answers1

7

It was not the custom adapter that was causing the problem, i was parsing the html data from the server which displayed the < as "<" and > comes as "&gt" so i replaced these two values

Spanned sp = Html.fromHtml(htmlstring.replace("&lt;", "<").replace("&gt;", ">"));
 textview.setText(sp);

And it worked fine..hope somebody gets help with this answer

George Thomas
  • 4,566
  • 5
  • 30
  • 65