There is a ViewPager and in it tabs with RecyclerView . On the RecyclerView element there is an icon favorites, which, when clicked, should change its appearance. At the moment it turns out that when you click on this item, the value for it in the database changes, but on the screen everything remains unchanged. For the FragmentStatePagerAdapter there is a method that updates the contents of the ViewPager adapter.notifyDataSetChanged(); . But I can't get it from the current fragment. Please help.

 public class ViewPagerPhraseAdapter extends FragmentStatePagerAdapter { private List<Fragment> fragmentList = new ArrayList<>(); private List<String> fragmentTitleList = new ArrayList<>(); public ViewPagerPhraseAdapter(FragmentManager fm) { super(fm); } // Возвращает фрагмент для отображения для этой страницы @Override public Fragment getItem(int position) { return PhraseFragmentTabPager.newInstance(position, fragmentTitleList.get(position)); } // Возвращает общее количество страниц @Override public int getCount() { return fragmentList.size(); } // Возвращает заголовок страницы для верхнего индикатора @Override public CharSequence getPageTitle(int position) { return fragmentTitleList.get(position); } public void addFragment(Fragment fragment, String title) { fragmentList.add(fragment); fragmentTitleList.add(title); } @Override public int getItemPosition(Object object) { return POSITION_NONE; } } 
  • If the adapter is in activation, make a method with calling the adapter update there, and in the fragment, cast getActivity () to the type of your activity and call the method - Yuriy SPb
  • in my case, it was necessary to declare the method as static - Maxim Fomichev

0