Domenico Giacomo Campanile

Sviluppatore e Consulente Informatico

Shows the fragment within a frameLayout Kotlin

Shows the fragment within a frameLayout in the fragment class

    val fragmentTransaction = fragmentManager?.beginTransaction()
    fragmentTransaction?.replace(R.id.frame_layout, fragment, tag)
    fragmentTransaction?.addToBackStack(tag)
    fragmentTransaction?.commit()
}

Shows the fragment within a frameLayout in the Activity class

    val manager: FragmentManager = supportFragmentManager
    val transaction: FragmentTransaction = manager.beginTransaction()
    transaction.add(R.id.frame_layout, fragment)
    transaction.commit()
}