Skip to content

Instantly share code, notes, and snippets.

@abelorian
Created September 10, 2014 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abelorian/04f4965952534e4d1bf1 to your computer and use it in GitHub Desktop.
Save abelorian/04f4965952534e4d1bf1 to your computer and use it in GitHub Desktop.
Cargar fragmentos a una actividad en Android
@Override
public void onNavigationDrawerItemSelected(int position) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment fragment = null;
switch (position){
case 0:
fragment = new Noticias();
break;
case 1:
fragment = new Videos();
break;
default:
fragment = new Noticias();
break;
}
fragmentTransaction.replace(R.id.container, fragment);
fragmentTransaction.commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment