How to skip image tag in html data in android?

My data in db is stored in html format along with image tags in it. Therefore, when I get data from the database, I remove the html tags and set them to textview. My problem, even after deleting the html tags, a small square field is displayed in the emulator indicating that there is an image. How can I remove these square fields in the emulator, which is an indicator of the image in the html data? Help me with this ...

Thanks in advance

My code is:

textView.setText(Html.fromHtml(htmlString));
+5
source share
4 answers

You can replace regex <img.+?>with htmlString.

textView.setText(Html.fromHtml(htmlString.replaceAll("<img.+?>", "")));

Not verified

+19
source

as the images may look like this:

<img ...></img>

and

<img... />

This solution will correspond to both cases:

String htmlBody = htmlString.replaceAll("<img.+/(img)*>", "");
textView.setText(Html.fromHtml(htmlBody));
+8

img.

String htmlBody = htmlString.replaceAll("(<(/)img>)|(<img.+?>)", "");

. .

+2
source

Hi look at this example

     String temp="<img>helloo</img><b> this is test</b>";
     temp=   temp.replace("<img>", "");
     temp=   temp.replace("</img>", "");
             textView.setText(Html.fromHtml(temp));
0
source

All Articles