3

I am currently parsing some HTML code and I would like to put in a Textview. (Webview is too much, I just want something very simple).

The Html.fromHtml(mySource) is great and working fine. This line makes my text turn in colors, bold, italic, etc...

Unfortunately, it has some inconvenients, it does not remove the comments.

Do you have any solution other than using a WebView?

enter image description here

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • 1
    If they are inside a ` – Quentin Jul 03 '11 at 10:59
  • You are totally right... Thank a lot for this information! – Waza_Be Jul 03 '11 at 11:09
  • However, since `Html.fromHtml()` cannot interpret ` – CommonsWare Jul 03 '11 at 12:06
  • Yes, you are totally right and your answer is accepted! Removing the first – Waza_Be Jul 03 '11 at 12:40

1 Answers1

2

Remove the comments yourself before passing the string to Html.fromHtml(). Whether you use a regular expression or an HTML parser is up to you, though this gentleman has an opinion on the matter.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hi, I am currently having the same problem. I'm not sure what to use to remove the comments. I'm using something like this String finalText = original.replaceAll("<[^>]*>", ""); to remove the comments but if I do this before Html.fromHtml(), it removes all of my text! – Sean Aug 31 '11 at 08:03