Bottom navigation part 2 in Android using Kotlin:

Bottom navigation
Step 1.  Add Framelayout in Layout File
Step 2. Create  fragment in android studio for your app
Step 3. How to use fragmentmanager to use fragment in your app

Load fragment in app on BottomNavigationView event 

Steps1. create new fragment->fragment blank of h fragment.kt and another of create aboutfragment.kt
Step2. fragment_home_xml-> attributes-> text-> I am  home fragment
 Step3. fragment_about_xml-> attributes-> text-> I am about fragment

Go to MainActivity.kt (code)

supportFragmentManager.begin Transaction ().add(,HomeFragment()).commit()

/*Part one logic
Val msg= when(it.itemID)
{>”About Selected”
else ->”Home selected”
Toast.make text(this @MainActivity,msg,Toast.LENGTH_LONG).show() /*

Val fragment=when(it.itemId)>AboutFragment()
   else->HomeFragment ()

SupportFragmentManager.begin Transaction ().replace( root_container, fragment).commit()

Leave a Reply

Your email address will not be published. Required fields are marked *