So I notice that when I press the button and open the drawer,the fragment is showing but next to drawer item. So I changed R.id.navMemories to drawer_layout and now its displaying
the final code:
// Create new fragment and transaction FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); GalleryFragment galleryFragment = new GalleryFragment(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.setReorderingAllowed(true); transaction.addToBackStack(null); // Replace whatever is in the fragment_container view with this fragment transaction.replace(R.id.drawer_layout, galleryFragment, null); // Commit the transaction transaction.commit();