URLからJPGを表示しようとしているときに、イメージをImageViewに表示する際に問題が発生しています。 URLConnectionを開き、InputStreamでイメージをプルダウンし、そのストリームをBitmapにデコードします。私はビットマップの高さと幅の値を取得することさえできます。ビットマップをImageViewに設定して、Drawableの高さを取得することができます。しかし、イメージはまだ私のアプリケーションに表示されません。私は何が欠けているかもしれないの任意のアイデア?助けてくれてありがとう。ビットマップがImageViewに表示されない
try{
URL imgURL = new URL(imgLocation);
URLConnection conn = imgURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 25);
Bitmap bm = BitmapFactory.decodeStream(bis);
if(bm != null){
System.err.println("Image Height: " + bm.getHeight());
System.err.println("Image Width: " + bm.getWidth());
} else {
System.err.println("bm is null!!!");
}
img.setImageBitmap(bm);
System.err.println("Drawable Height: " + img.getDrawable().getIntrinsicHeight());
} catch (IOException e) {
// Print out the exception that occurred
e.printStackTrace();
}