因此,我尝试使用FirebaseRecyclerAdapter的要点如下:
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<String, FSViewHolder> adapter = new FirebaseRecyclerAdapter<String, FSViewHolder>(
String.class,
android.R.layout.two_line_list_item,
FSViewHolder.class,
fsRef
) {
@Override
protected void populateViewHolder(FSViewHolder viewHolder, String model, int position) {
}
};
}
public static class FSViewHolder extends RecyclerView.ViewHolder {
TextView fsText;
public FSViewHolder(View v) {
super(v);
fsText = (TextView) v.findViewById(android.R.id.text1);
}
}
当我在工作室运行应用程序时,我收到一条错误消息,上面写着:
错误:(88,65(错误:找不到适用于FirebaseRecyclerAdapter(Class,int,Class,Firebase(的构造函数构造函数FirebaseRecyclerAdapter.FirebaseRecycleAdapter(Class、int、Class、Query(不适用(参数不匹配;Firebase无法转换为Query(构造函数FirebaseRecyclerAdapter。FirebaseRecrylerAdapter(Class、int、Class、DatabaseReference(不适用(参数不匹配;Firebase无法转换为DatabaseReference(
我真的很困惑。有人能告诉我我做错了什么吗?
fsRef的类型似乎不对。FirebaseRecyclerAdapter的超级构造函数需要DatabaseReference,而fsRef是Firebase的。我认为它一定是FirebaseDatabase.getInstance().getReference()
。该链接可能有助于firebase.google.com/docs/database/android/recovere-data