I have a fragment with a custom recycerview that is filled using a REST call. When i click a list item pops up a dialog. I want to reset that list whenever i get out of the dialog. I found the following code:
FragmentManager manager = ((AppCompatActivity) context).getSupportFragmentManager();
Fragment currentFragment = manager.findFragmentByTag("productTag");
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
When i hit the onClick button (a way to get out of dialog) app crashes and logcat says:
Attempt to invoke virtual method 'void androidx.fragment.app.Fragment.setNextAnim(int)' on a null object reference
As much as I understood i should be able to call the fragment with the code above though it keeps on crashing. So is that the problem or maybe something entirely different?
You can follow a process like below.
In your Adapter set a listener which will be implemented in Fragment used to update whatever you want in fragment.