如何修复E / RecyclerView:未连接适配器;跳过布局问题

时间:2019-04-05 18:34:12

标签: java android android-recyclerview

解决E / RecyclerView问题:未连接适配器;在应用打开期间跳过布局。

private RecyclerView recyclerView;

private UserAdapter userAdapter;
private List<User> mUsers;

FirebaseUser fuser;
DatabaseReference reference;

private List<Chatlist> usersList;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_chats, container, false);

    recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

    fuser = FirebaseAuth.getInstance().getCurrentUser();

请帮助

1 个答案:

答案 0 :(得分:0)

您似乎在文件顶部声明了一个适配器,但是我看不到您是在适配器上设置数据源,然后在回收站上设置适配器,如下所示:

userAdapter = new UserAdapter(mUsers);
recyclerView.setAdapter(userAdapter);

还,您编写了完整的UserAdapter吗?

Google提供了一些出色的文档,其中包含有关如何实现Recyclerview的示例: https://developer.android.com/guide/topics/ui/layout/recyclerview