Answers for "replace fragment in fragment manager"

0

replace fragment in new layout android

FragmentManager fm = getFragmentManager();

if (fm != null) {
    // Perform the FragmentTransaction to load in the list tab content.
    // Using FragmentTransaction#replace will destroy any Fragments
    // currently inside R.id.fragment_content and add the new Fragment
    // in its place.
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container, new YourFragment());
    ft.commit();
}
Posted by: Guest on December-26-2021

Browse Popular Code Answers by Language