代码:
@Override
public void onStart() {
super.onStart();
recyclerViewadapter=new FirebaseRecyclerAdapter<RecycleModel, UserViewHolder>(RecycleModel.class, R.layout.recycler_model, UserViewHolder.class, muserDB)
{
@Override
protected void onBindViewHolder(@NonNull UserViewHolder holder, int position, @NonNull RecycleModel model) {
}
@NonNull
@Override
public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
};
答案 0 :(得分:0)
要解决此问题,请使用以下代码:
FirebaseRecyclerOptions<RecycleModel> firebaseRecyclerOptions = new FirebaseRecyclerOptions.Builder<RecycleModel>()
.setQuery(muserDB, RecycleModel.class)
.build();
recyclerViewadapter=new FirebaseRecyclerAdapter<RecycleModel, UserViewHolder>(firebaseRecyclerOptions) {
@Override
protected void onBindViewHolder(@NonNull UserViewHolder holder, int position, @NonNull RecycleModel model) {
// set the model to the holder
}
@NonNull
@Override
public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
};
FirebaseRecyclerAdapter
类将最后一个版本作为FirebaseRecyclerOptions
对象的构造函数中的参数,而不再是这4个参数。
如果您有兴趣,建议使用 this ,您可以从Firebase Realtime数据库中检索数据并使用{{1}在RecyclerView
中显示数据}。