everyone, my issue is :
I'm in ProfilFragment, that was generated with the Menu Drawer it extends Fragment, and I can't change this (it broke some other part). When I click on a button I want to refresh my current Fragment
// Reload current fragment
Fragment frg = null;
frg = getActivity().getSupportFragmentManager().findFragmentById(R.id.nav_profil);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();
I found this on other StackOverflow issues but it didn't work for me.
frg = getActivity().getSupportFragmentManager().findFragmentById(R.id.nav_profil);
Always return null
Even if in my mobile_navigation.xml
I have
<fragment
android:id="@+id/nav_profil"
android:name="com.example.pierregignoux.ui.profil.ProfilFragment"
tools:layout="@layout/fragment_profil" />
Any help would be great, Thanks a lot.
just run this
getActivity().getSupportFragmentManager().beginTransaction().detach(this).attach(this).commit();