首页 > 解决方案 > 适配器项目刚刚消失

问题描述

视频预览:

在此处输入图像描述

回收者的观点有时会不知从何处消失,有时不会。

有人可以向我解释为什么会这样吗?

    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);
     }

标签: androidandroid-recyclerview

解决方案


推荐阅读