//判断string中是否包含img标签 if (!TextUtils.isEmpty(content) && content.indexOf("<img") != -1) { //img标签正则 String regEx_img = "<img.*src\\s*=\\s*(.*?)[^>]*?>"; Pattern p_image = Pattern.compile(regEx_img, Pattern.CASE_INSENSITIVE); Matcher m_image = p_image.matcher(content); //循环去掉img标签 while (m_image.find()) { String group = m_image.group(); Log.e("fhxx", "html--->" + group); content = content.replace(group, ""); Log.e("fhxx", "截取--->" + content); } } textview.setText(Html.fromHtml(content));
android 去掉富文本(html代码)中的img标签
猜你喜欢
转载自blog.csdn.net/jiexiao4151/article/details/120828316
今日推荐
周排行