Skip to content

Instantly share code, notes, and snippets.

@enginebai
Last active December 8, 2015 09:46
Show Gist options
  • Save enginebai/760a05533d7554db4537 to your computer and use it in GitHub Desktop.
Save enginebai/760a05533d7554db4537 to your computer and use it in GitHub Desktop.
@Override
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment fragment;
String fragmentTag;
switch (position) {
case 0:
fragment = MoviePageFragment.newInstance();
fragmentTag = MoviePageFragment.class.getSimpleName();
break;
default:
fragment = PlaceholderFragment.newInstance(position + 1);
fragmentTag = PlaceholderFragment.class.getSimpleName();
}
fragmentTransaction
.replace(R.id.container, fragment, fragmentTag)
.commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment