android - 适配器项目刚刚消失
问题描述
视频预览:
回收者的观点有时会不知从何处消失,有时不会。
有人可以向我解释为什么会这样吗?
postAdapter = new PostAdapter(getActivity(), postList, userPreferences);
linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setReverseLayout(true);
linearLayoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(postAdapter);
pullRefreshLayout.setRefreshing(true);
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, String previousChildName) {
Post p = dataSnapshot.getValue(Post.class);
postKeys.add(dataSnapshot.getKey());
postList.add(p);
postAdapter.notifyItemInserted(postList.size() - 1);
pullRefreshLayout.setRefreshing(false);
}
解决方案
推荐阅读
- python-3.x - Python 慢慢爬取网站
- php - 如何通过文件ID为谷歌驱动器链接生成直接下载链接
- android - gradle 错误 - com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector
- scala - 如何拦截使用 Akka HTTP 发出的 HTTP 客户端请求?
- regex - 在文件中查找字符串并在 Linux 中执行部分数学运算
- ios - iOS 11.2 之前的订阅促销
- android - CountDown Timer 不会在 Android 中停止 Value ListView
- javascript - Ajax Load 在 setTimeout 中递归工作?
- unity3d - 从 Unity 访问 TrueDepth
- go - go/importer.Import 在生产中返回错误“找不到导入”