0

The response of a web service is the following :

<span style="color:#DDFFEE;">You have to pay you bil before <b>12 june 2012</b> for your informations.</span></br></br> You have already a large time.

I want to display this in a TextView.

I can't just simply put the response below in a String and applicate

myTextView.setText(Html.fromHtml(response));

It doesn't work because it can't be a String.

How can I do this dynamically please ?

enter image description here

2 Answers2

0

You just need to put the String you get as a response, inside the fromHtml call, if it's not a String, maybe you just need to append .toString() to it, to get a String..

textView.setText(Html.fromHtml("<h2>This is HTML</h2>"));
Juan Cortés
  • 20,634
  • 8
  • 68
  • 91
0

You need to use Html.fromHtml() to use HTML in your XML Strings. Simply referencing a String with HTML in your layout XML will not work.

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

here : Similar question

Community
  • 1
  • 1
EL Kamel
  • 824
  • 2
  • 12
  • 27
  • You don't understand the question, my issue is that the response from web service can't be a String. I got errors. –  May 27 '14 at 09:52
  • response is an object ?? what type it has ?? you can convert it to a string .toString() – EL Kamel May 27 '14 at 10:30