Hello!
When working with RecyclerView, you need to update its visual component. But you have to sculpt crutches. Why?

//Не работает // tempMedicineList = db.readAll(); // recyclerView.getAdapter().notifyDataSetChanged(); //Костыль, который работает if (recyclerView.getAdapter() != null) { recyclerView.setAdapter(null); } MedicineAdapter medicineAdapter = new MedicineAdapter(this, db.readAll()); medicineAdapter.setOnClickListener(this); recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); recyclerView.setAdapter(medicineAdapter); 
  • The known problem is such a crutch - pavlofff
  • Try this: tempMedicineList.clear(); tempMedicineList.addAll(db.readAll()); recyclerView.getAdapter().notifyDataSetChanged(); tempMedicineList.clear(); tempMedicineList.addAll(db.readAll()); recyclerView.getAdapter().notifyDataSetChanged(); - Yura Ivanov

1 answer 1

notifyDataSetChanged works fine only if the transferred collection or array is changed (added, changed, deleted). Nothing more. Replacing the entire collection / array is also not considered.

  • It would be nice to add some code in response. - eugeneek