在網站http://218.93.33.59:85/map/zjmap/ibikegif.asp?flag=2&id=9
上,我們可以得到一個名爲ibikegif.gif的gif圖像。但是我無法在我的android手機上顯示它。我的代碼是這樣的:爲什麼我無法在Android平臺上顯示圖像
/**
*@param url the imageURL.it references to
*"http://218.93.33.59:85/map/zjmap/ibikegif.asp?flag=2&id=9" here
*
**/
public Bitmap returnBitMap(String url) {
URL myFileUrl = null;
Bitmap bitmap = null;
try {
myFileUrl = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is); //Attention:bitmap is null
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
你能幫我嗎?
您是否將位圖設置爲imageview?imageView.setImageBitmap(bitmap); – Raghunandan 2013-05-09 05:58:17
位圖爲空,所以我無法顯示使用ImageView的圖像。 – WikiStyle 2013-05-09 06:18:39
當你把'conn.connect'後面的conn.getResponseCode(),它返回什麼? – iBecar 2013-05-09 07:43:53