Answers for "start fragment from activity kotlin"

2

open fragment from activity kotlin

if (savedInstanceState == null) {
            val f = DnsTestFragment()
            val t: FragmentTransaction = supportFragmentManager.beginTransaction()
            t.replace(binding.findastestFramelayout.id, f).commit()
        }
Posted by: Guest on August-17-2021
1

start fragment from activity

FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.container,YOUR_FRAGMENT_NAME,YOUR_FRAGMENT_STRING_TAG);
transaction.addToBackStack(null);
transaction.commit();
Posted by: Guest on November-06-2020
-1

how to start activity from fragment in kotlin

activity?.let{
    val intent = Intent (it, Main::class.java)
    it.startActivity(intent)
}
Posted by: Guest on February-15-2021

Code answers related to "start fragment from activity kotlin"

Browse Popular Code Answers by Language