I have retrieved JSON value to show it in android TextView
This is my sample JSON Value
"introtext": "The District Administration Office has sealed the case was underway.<img src="images/dec_09_Lazimpat_road_b.JPG" alt="" />"
I used Apache Common lang Liabrary to escape HTML attributes and styles like this.
String str = org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4(stringValue);
and I have set the value to TextView
like this
textView.setText(Html.fromHtml(str));
Everything worked fine till here but the text
in TextView
is shown like in this image
This small blue box is shown where img src
attribute is there. I've wasted too long time trying to remove this. Please help me how to remove this box from TextView
. Any help will be appreciated.
Try this code:
String s = "The District Administration Office has sealed the case was underway.<img src="images/dec_09_Lazimpat_road_b.JPG" alt="" />";
String str = Html.fromHtml(s).toString();
///// Remove all img tags using Regular Expression
str = str.replaceAll("[<](/)?img[^>]*[>]", "");
textView.setText(Html.fromHtml(str));