/** Returns a new instance of this fragment for the given section number. */ public static InventoryFragment newInstance(int sectionNumber) { InventoryFragment fragment = new InventoryFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; }
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); switch (position) { case 2: fragmentManager .beginTransaction() .replace(R.id.container, NotificationFragment.newInstance(position + 1)) .commit(); break; case 3: fragmentManager .beginTransaction() .replace(R.id.container, InventoryFragment.newInstance(position + 1)) .commit(); break; default: fragmentManager .beginTransaction() .replace(R.id.container, HomeFragment.newInstance(position + 1)) .commit(); break; } }