簡體   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