I made FirestoreRecycleview in home-menu, when run app FirestoreRecycler
work properly but when I open other Menu in Bottom Navbar, FirestoreReclyclerview
not Load data
for Example :
This is When run app in First Time :
This is After I Click other navbar button and open this fragment again :
this is my code that I call in onCreate()
private void setkelaslist() {
Query query = fdb.collection("kelas").whereEqualTo("email",email_txt);
FirestoreRecyclerOptions<kelas_profil> options = new FirestoreRecyclerOptions.Builder<kelas_profil>().
setQuery(query,kelas_profil.class)
.build();
adapter = new listkelasadapter(options,this);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
adapter.startListening();
adapter.notifyDataSetChanged();
recyclerView.setAdapter(adapter);
}
Another request: one more question, I delete items with a button click, it is deleted but when I create a new item with same data, in Toast it says Complete but it doesn't add data.
You forgot adding start listening method for your adapters.
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}