在 Android 中设置动态画廊时,它对我不起作用
我是 Android 新手。我有一个画廊,其中显示来自 URL 的图像。第一次设置图库时看不到图像,当我滚动图库时,所有图像都已设置。我登录了 Adapter(派生自 BaseAdapter)的 getView()
,发现 getView
仅在我单击该项目后才起作用。 怎么解决这个问题..
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iv = new ImageView(context);<br>
//method that displays image from url
imageLoader.displayImage(myimageurls[arg0], activity, iv);
Log.i("Gallery", "Image URL = " + myimageurls[arg0]);<br>
}
I'm a newbie to Android. I have a gallery in which images are displayed from URL. I cannot see the images when the gallery is set up for the first time, When I scroll the gallery, then all the images are set. I logged in getView()
of Adapter (derived from BaseAdapter), and saw that getView
works only after I clicked the item.
How to resolve this..
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iv = new ImageView(context);<br>
//method that displays image from url
imageLoader.displayImage(myimageurls[arg0], activity, iv);
Log.i("Gallery", "Image URL = " + myimageurls[arg0]);<br>
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在图库初始化后立即从适配器调用 notificationDataSetChanged() 。这会强制重绘特定的 AdapterView(本例中为图库)
JQCorreia
Try calling notifyDataSetChanged() from your adapter right after the initialization of your gallery. This forces a redraw on that particular AdapterView (Gallery in this case)
JQCorreia