I cant see any FirebaseRecyclerAdapter items on my layout
Solution 1:
The tutorial that you are following is wrong. To solve your problem, please consider following these steps.
-
Move all the code from the
onStart()
method insideonCreate()
method except these two lines of code:super.onStart(); firebaseAuth.addAuthStateListener(authStateListener);
-
Make your
firebaseRecyclerAdapter
varaible global:private FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter;
Remove
FirebaseRecyclerAdapter<Blog, BlogViewHolder>
from theonCreate()
method.-
Add the following lines of code in the
onStart()
andonStop()
methods.@Override protected void onStart() { super.onStart(); firebaseRecyclerAdapter.startListening(); } @Override protected void onStop() { super.onStop(); if(firebaseRecyclerAdapter != null) { firebaseRecyclerAdapter.stopListening(); } }
-
The most important thing is to remove the
static
keyword from your class declaration. Should be only:public class PostViewHolder extends RecyclerView.ViewHolder {}