繁体   English   中英

如何向WebView添加Drawable

[英]How to add a Drawable to WebView

杰森

 {
   "text": "  «Le président du Bloc du Changement et de la Réforme",
   "imagepath": "http://www.example.com/dori%20chamoun-saidaonline.jpg"
  }

我获取文本并从URL获取图像作为可绘制图像

 introtext = jArray.getString("introtext");

 InputStream is = bufferedHttpEntity.getContent();
 Drawable image = Drawable.createFromStream(is, "src");

我的问题是,我想在同一WebView中显示图像和文本。

有什么帮助吗?

Drawable中不需要。 您可以使用WebView的loadData方法。 例如:

String content="<html><body><img src=\""+image_path+"\" /><br/>"+your_text+"</body></html>";
wview.loadData(content,"text/html",null);

wview是您的WebView, image_path是图像路径, your_text是您的文本(这里没有任何惊喜)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM