iam使用xml解析器,我的問題無法在webview上顯示imageURL。在網頁流量數據從列表視圖中獲得,但在列表視圖可以顯示圖像的URL我無法在webview中顯示圖像
這是我在web視圖代碼
static final String KEY_HEADLINE = "Headline";
static final String KEY_ARTICLEDATE = "ArticleDate";
static final String KEY_BODY = "Body";
static final String KEY_IMAGEURL = "ImageURL";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webnews);
// getting intent data
Intent in = getIntent();
Bundle bun = in.getExtras();
//Get XML values from previous intent
String headline = bun.getString(KEY_HEADLINE);
String date = bun.getString(KEY_ARTICLEDATE);
String Body = bun.getString(KEY_BODY);
String image = bun.getString(KEY_IMAGEURL);
Log.i("Result "+KEY_HEADLINE, headline);
WebView browser = (WebView)findViewById(R.id.webView1);
String HTML = "<div style='margin-top:5px; margin-left:5px; margin-right:5px;margin- bottom;5px;'></div>
<div style='font-family:Arial;font-size:14px;fontcolor:gray;'>"+date+"</div><div><strong style='font-family:Arial; font-size:24; margin-bottom:5;'>"+headline+"</strong></div>
<div><div style='float: margin-left:2px ;margin-right: 2px;margin-bottom: 1px; margin-top: 25px;'><center><img src="+image+" alt='' style='width:200px; height:127px; margin-bottom:20px;'</center></div>
<div style='line-height: 20px;font-size:16px; font-family:Arial'>"+Body+"</div></div></div>" ;
browser.loadData(HTML, "text/html", "utf-8");
你需要在src標籤中編碼你的圖片在html中,然後顯示在webview – KOTIOS