0
我有问题,当图像未加载后notifyDataSetChanged
总的来说,我有启动类,我开始从网站加载图像,并将它们保存在设备上。并且适配器使用设备上保存的图像。所以如果我在保存图像之前打开我的列表视图,我只能看到我的占位符。然后,如果我返回哟应用程序,那么当然imageas ar加载,因为他们已经保存。android适配器notifydatasetchanged工作不正常
创建适配器
adapter = new GridAdapter(getActivity(), grid, 6);
grid.setAdapter(adapter);
在这里,我保存的图像,并通知适配器。
try {
FileOutputStream fos = context.openFileOutput(String.valueOf(id)+".jpg", Context.MODE_PRIVATE);
fos.write(imageBytes);
fos.close();
try {
GridFragment.adapter.notifyDataSetChanged();
} catch (Exception e) {
// TODO: handle exception
}
。 而在适配器我使用imageloading库,而只是它只是规定了从设备(未异步等)
iLoader.displayImage("file:///"+mContext.getFileStreamPath
(String.valueOf(position)).toString()+".jpg", holder.imageView, DataHolder.options, this);
是什么GridAdapter? – gaurav5430
其“BaseAdapter” –
你检查了我的答案吗?它也适用于基础适配器。它有帮助吗? – gaurav5430