Skip to content Skip to sidebar Skip to footer

No View Found For Id 0x7f0800c4 For Fragment

I get this error when I am trying to replace the parent fragment (SearchFragment) from the child fragment (ClassroomsTab) in a swipe tab viewPager. Basically what I am trying to ac

Solution 1:

This usually happens when you change the layouts in several transactions. the same happened to me and I solved it by clearing the stack behind it. but you have to use a single FragmentManagerfor all of your transactions. put this code after you done the transaction

    private void clearStack() {
    if (fragmentManager.getBackStackEntryCount() > 0) {
        for (int i = 0; i < fragmentManager.getBackStackEntryCount(); i++) {
            fragmentManager.popBackStack();
        }
    }

    if (fragmentManager.getFragments().size() > 0) {
        for (int i = 0; i < fragmentManager.getFragments().size(); i++) {
            Fragment mFragment = fragmentManager.getFragments().get(i);
            if (mFragment != null) {
                fragmentManager.beginTransaction().remove(mFragment).commit();
            }
        }
    }
}

Post a Comment for "No View Found For Id 0x7f0800c4 For Fragment"