适配器项目消失了

时间:2019-06-17 23:40:47

标签: android recycler-adapter

视频预览:

enter image description here

回收者的观点有时无处不在,有时甚至消失。

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

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

0 个答案:

没有答案