Java FireBaseRecyclerView中的FireBaseRecyclerView无法应用于:(参数)

Java FireBaseRecyclerView中的FireBaseRecyclerView无法应用于:(参数),java,android,firebase,firebase-realtime-database,firebaseui,Java,Android,Firebase,Firebase Realtime Database,Firebaseui,我正在尝试从Firebase检索数据到Recyclerview。我已经实现了所有其他步骤,但现在我在实现适配器(FirebaseRecyclerAdapter)的最后阶段遇到了错误 我的片段 public class Journal extends Fragment { RecyclerView recyclerView; DatabaseReference myref; @Override public View onCreateView(LayoutInflater inflater, @

我正在尝试从Firebase检索数据到Recyclerview。我已经实现了所有其他步骤,但现在我在实现适配器(FirebaseRecyclerAdapter)的最后阶段遇到了错误

我的片段

public class Journal extends Fragment {

RecyclerView recyclerView;
DatabaseReference myref;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_journal,container,false);
    myref= FirebaseDatabase.getInstance().getReference("/Journal");
    recyclerView = (RecyclerView) v.findViewById(R.id.journal_rv);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    FirebaseRecyclerAdapter<JournalEntry, JournalHolder> adapter = new FirebaseRecyclerAdapter<JournalEntry, JournalHolder>(
            JournalEntry.class,
            R.layout.journal_list_item,
            JournalHolder.class,
            myref) {
        @Override
        protected void onBindViewHolder(JournalHolder holder, int position, JournalEntry model) {
            holder.setTitle(model.getEvent_title());
            holder.setContent(model.getEvent_content());
            holder.setSchool(model.getSchool_name());
            holder.setDate(model.getDate());
            holder.setStudents(model.getNumber_of_students());
            holder.setSchoolIv(model.getImg_url());
        }

        @Override
        public JournalHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return null;
        }
    };

return  v;
}
public static class JournalHolder extends RecyclerView.ViewHolder{
    TextView Jtitle , Jcontent,Jschool,Jstudents,jdate;
    ImageView schoolIV;
    public JournalHolder(View itemView) {
        super(itemView);
        Jtitle =(TextView)itemView.findViewById(R.id.journal_title);
        Jcontent =(TextView)itemView.findViewById(R.id.event_content);
        Jschool =(TextView)itemView.findViewById(R.id.journal_school);
        Jstudents =(TextView)itemView.findViewById(R.id.journal_students);
        jdate =  (TextView)itemView.findViewById(R.id.journal_dates) ;
        schoolIV = (ImageView)itemView.findViewById(R.id.journal_image);





    }

    public void setTitle(String title) {
        Jtitle.setText(title);
    }

    public void setContent(String content) {
        Jcontent.setText(content);
    }

    public void setSchool(String school) {
        Jschool.setText(school);
    }

    public void setDate(String date) {
        jdate.setText(date);
    }

    public void setStudents(String students) {
        Jstudents.setText(students);
    }

    public void setSchoolIv(String schoolIv) {
        Picasso.with(itemView.getContext())
                .load(schoolIv)
                .into(schoolIV);
    }
}
}
请帮帮我。我尝试了所有的方法,但都不管用。 或者如果你有任何建议…提前谢谢你

PS:我正在使用片段

在活动声明下写下:-

  private FirebaseRecyclerAdapter<JournalEntry, JournalHolder> adapter;
使用此方法而不是onBindViewHolder:

 @Override
        protected void populateViewHolder(JournalHolder holder,JournalEntry model, int position) {

确保您在模型类JournalEntry.class和holder类JournalHolder.class中拥有所有正确的方法,并且它的位置和布局正确。

我终于在这里找到了解决方案:

我也遇到了同样的问题。 在此版本中,FirebaseResycleView使用以下内容:

  Query query = FirebaseDatabase.getInstance()
            .getReference(); // you can add child as .child("child_name");


  FirebaseRecyclerOptions<JournalEntry> options = new FirebaseRecyclerOptions.Builder<JournalEntry>()
            .setQuery(query, JournalEntry.class)
            .build();

  FirebaseRecyclerAdapter<JournalEntry, JournalHolder> adapter = new FirebaseRecyclerAdapter<JournalEntry, JournalHolder>(
        options) {
    @Override
    protected void onBindViewHolder(JournalHolder holder, int position, JournalEntry model) {
        holder.setTitle(model.getEvent_title());
        holder.setContent(model.getEvent_content());
        holder.setSchool(model.getSchool_name());
        holder.setDate(model.getDate());
        holder.setStudents(model.getNumber_of_students());
        holder.setSchoolIv(model.getImg_url());
    }

    @Override
    public JournalHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.journal_list_item, parent, false);
            return new JournalHolder(view);
    }
};

您是否在build.gradle编译'compile'com.firebaseui:firebaseui数据库:x.x.x'中编写//我指的是最新版本在错误中显示为blogviewholder但您有journalholder作为参数我正在使用firebase ui database 11.4.2,关于该错误,我已经更改为blogviewholder,但仍然相同。不工作?我也尝试过这个方法,但它不起作用。新的错误是类“从FirebaseRecyclerAdapter派生的匿名类”必须声明为抽象的,或者在“适配器”中实现抽象方法“oncreateViewHolder(ViewGroup,int)”。当我实现该方法时,我有相同的代码。@user8773560您是否在,
公共类日志扩展片段下编写声明{
?是的,可能是我使用了错误的firebare ui数据库吗?不,这不是问题,而不是
onBindViewHolder
尝试
populateViewHolder
,但是保留参数sameThankБММиииииПииццццццццццццц还有吗?
     recyclerView.setAdapter(adapter);
 @Override
        protected void populateViewHolder(JournalHolder holder,JournalEntry model, int position) {
  Query query = FirebaseDatabase.getInstance()
            .getReference(); // you can add child as .child("child_name");


  FirebaseRecyclerOptions<JournalEntry> options = new FirebaseRecyclerOptions.Builder<JournalEntry>()
            .setQuery(query, JournalEntry.class)
            .build();

  FirebaseRecyclerAdapter<JournalEntry, JournalHolder> adapter = new FirebaseRecyclerAdapter<JournalEntry, JournalHolder>(
        options) {
    @Override
    protected void onBindViewHolder(JournalHolder holder, int position, JournalEntry model) {
        holder.setTitle(model.getEvent_title());
        holder.setContent(model.getEvent_content());
        holder.setSchool(model.getSchool_name());
        holder.setDate(model.getDate());
        holder.setStudents(model.getNumber_of_students());
        holder.setSchoolIv(model.getImg_url());
    }

    @Override
    public JournalHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.journal_list_item, parent, false);
            return new JournalHolder(view);
    }
};
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    adapter.startListening();