为 ImageAdapter 异步获取远程图像
我有一个 getView() 的 Android Gallery ImageAdapter 实现,如下所示:
public View getView(int arg0, View arg1, ViewGroup arg2) {
String strURL = "http://app1.exactdev.co.za/android/celebs/celeb" + (arg0+1) + ".jpg";
Bitmap bm = RemoteBitMapHelper.getRemoteBitMap(strURL); //synchronous request
ImageView i = new ImageView(ctx);
i.setImageBitmap(bm);
return i;
}
How can I make getView do it job asynchronously?
I have an Android Gallery ImageAdapter implementation for getView() that looks as follows:
public View getView(int arg0, View arg1, ViewGroup arg2) {
String strURL = "http://app1.exactdev.co.za/android/celebs/celeb" + (arg0+1) + ".jpg";
Bitmap bm = RemoteBitMapHelper.getRemoteBitMap(strURL); //synchronous request
ImageView i = new ImageView(ctx);
i.setImageBitmap(bm);
return i;
}
How can I make getView do its job asynchronously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的答案是您可以将其放入 AsyncTask 中。类似于以下内容(未经测试)
The simple answer is you could put it inside an AsyncTask. Something like the following (untested)