how can i change the top bar while working with navigation?

  1. override onCreateOptionsMenu() in MainActivity.

     override fun onCreateOptionsMenu(menu: Menu?): Boolean {
         super.onCreateOptionsMenu(menu)
         menuInflater.inflate(R.menu.menu_second, menu)
         return true
     }
    
  2. create menus in res folder

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <item android:id="@+id/menu_next"
            android:title="toNext"
            android:titleCondensed="next"
            android:orderInCategory="1"
            android:icon="your icon"
            app:showAsAction="always" />
    </menu> 
    

menu api

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top