0

重複の可能性:
gridviewで画像の遅延読み込みを実装する方法

AndroidでDrawableを使用してURLから複数の画像を取得するにはどうすればよいですか?

private Drawable LoadImageFromWebOperations(String url) {
        try {
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "icon");
            return d;
        } catch (Exception e) {
            System.out.println("Exc=" + e);
            return null;
        }
    }

この関数を使用して描画可能な画像を返していますが、画像のリストをグリッドビューにバインドする方法がわかりません。

私を助けてください。

4

2 に答える 2

1

「imgaeUrl」フィールドにURLを指定するだけです

URL url = new URL(imageUrl);
HttpURLConnection connection  = (HttpURLConnection) url.openConnection();

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);  

imageView.setImageBitmap(img );

そしてimageviewを設定します

于 2012-12-01T07:14:39.670 に答える
0

このhttp://android-developers.blogspot.in/2010/07/multithreading-for-performance.htmlを確認できます。それはあなたを導くことができます

于 2012-12-01T07:33:13.043 に答える