Skip to content

Instantly share code, notes, and snippets.

@gunhansancar
Created September 25, 2017 08:23
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 gunhansancar/7f5d77b469bae58e632166d5115b233a to your computer and use it in GitHub Desktop.
Save gunhansancar/7f5d77b469bae58e632166d5115b233a to your computer and use it in GitHub Desktop.
fragment_container could be any layout in your activities main layout xml. It will attach Fragment's layout on this container layout.
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment fragment = MyFragment.newInstance("Gunhan", 28);
fragmentTransaction.add(R.id.fragment_container, fragment);
fragmentTransaction.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment