Skip to content

Instantly share code, notes, and snippets.

@AreJay-Smith
Last active July 17, 2018 20:01
Show Gist options
  • Save AreJay-Smith/46e899deeb81c14c3a4cf8398816570a to your computer and use it in GitHub Desktop.
Save AreJay-Smith/46e899deeb81c14c3a4cf8398816570a to your computer and use it in GitHub Desktop.
Replace Fragment
// Create new fragment (Either map or list fragment) and the transaction
val listFragment = ListFragment()
val transaction = fragmentManager!!.beginTransaction()
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack if needed
transaction.replace(R.id.fragment_container, listFragment)
transaction.addToBackStack(null)
// Commit the transaction
transaction.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment