Can someone please tell what\'s the error enter image description here
Here is my code
package com.andisofttechnology.myapplication.Model;
import a
You are already using the FirebaseRecyclerOptions
:
FirebaseRecyclerOptions<Category> options =
new FirebaseRecyclerOptions.Builder<Category>()
.setQuery(MenuViewHolder, Category.class)
.build();
The constructor FirebaseRecyclerAdapter
takes a variable of type FirebaseRecyclerOptions
as specified here:
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java#L37
Change this:
FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {
into this:
FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(options) {
You need implement FirebaseRecyclerAdapter like that:
FirebaseRecyclerAdapter<YourModel, YourModelViewHolder> firebaseUsersAdapter = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseRecyclerOptions<YourModel> options = new FirebaseRecyclerOptions.Builder<YourModel>()
.setQuery(query, YourModel.class)
.build();
firebaseUsersAdapter = new FirebaseRecyclerAdapter<YourModel, YourModelViewHolder>(
options) {
@Override
protected void onBindViewHolder(YourModelViewHolder holder, int position, Users model) {
holder.name.setText(model.getName());
...
}
@Override
public YourModelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.R.layout.menu_item, parent, false);
return new YourModelViewHolder(view);
}
};
mAllUsersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAllUsersRecyclerView.setAdapter(firebaseUsersAdapter);
firebaseUsersAdapter.startListening();
I hope this helps you.