对我来说,notifyItemInserted in runOnUiThread不起作用。在下载每个文件后,我在runOnUiThread中使用了asyncTask:
ImageModel imageModel = new ImageModel();
imageModel.setName("تصویر " );
imageModel.setUrl(aFile.getName());
imageModel.ImageFile = localFile;
data.add(imageModel);
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.notifyItemInserted(data.size() - 1);
}
});发布于 2016-08-16 15:26:36
不能直接回答为什么它不能工作,但是我建议调用publishProgress(),然后在异步任务中调用onProgressUpdate(),将适配器调用放在没有runOnUiThread的地方。
https://stackoverflow.com/questions/38978671
复制相似问题