title: I dont know why my navigationview click event is not working with navigation view
body: <p>I cant set onclicklistener for navigationview in this code the menu is working but the menu items in navigation view is not working i have tried in options item selected and navigationitemselected listener too but its not working i have set the id in menu item and id in nav graph same but its not working</p>
  <pre><code> package com.nads.epicureapp
  
   import android.content.Context
   import android.content.res.Configuration
   import androidx.appcompat.app.AppCompatActivity
   import android.os.Bundle
   import android.util.Log
   import android.view.Menu
   import android.view.MenuItem
   import androidx.appcompat.widget.Toolbar
  import androidx.drawerlayout.widget.DrawerLayout
  import androidx.navigation.NavController
  import androidx.navigation.findNavController
  import androidx.navigation.fragment.NavHostFragment
  import androidx.navigation.ui.*
  import androidx.navigation.ui.NavigationUI.onNavDestinationSelected
  import androidx.navigation.ui.NavigationUI.setupWithNavController
  
  import com.google.android.material.navigation.NavigationView
  import com.nads.epicureapp.databinding.ActivityMainBinding
  import dagger.hilt.android.AndroidEntryPoint
  import androidx.navigation.ui.navigateUp
  import com.google.android.material.bottomnavigation.BottomNavigationView
  
  @AndroidEntryPoint
  class MainActivity : AppCompatActivity(),NavigationView.OnNavigationItemSelectedListener{
  
  
  
  
  private lateinit var appBarConfiguration : AppBarConfiguration
  private lateinit var navController:NavController
  private lateinit var  binding: ActivityMainBinding
  private lateinit var toolbar:Toolbar
  private lateinit var navHostFragment: NavHostFragment
  private lateinit var drawerLayout:DrawerLayout
  private lateinit var navView:NavigationView
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      binding = ActivityMainBinding.inflate(layoutInflater)
      setContentView(binding.root)
      toolbar = binding.root!!.findViewById&lt;Toolbar&gt;(R.id.toolbar)
      setSupportActionBar(toolbar)
      navHostFragment =
          supportFragmentManager.findFragmentById(R.id.fragmentactivatedformain) as NavHostFragment
  
      navController = navHostFragment.navController
      drawerLayout = binding.root!!.findViewById(R.id.drawer_layout)
      navView = binding.root!!.findViewById&lt;NavigationView&gt;(R.id.nav_view)
      appBarConfiguration = AppBarConfiguration(setOf(R.id.homeFragment,R.id.profilePage,R.id.settings_dest),drawerLayout)
      navView.setupWithNavController(navController)
      navView.setNavigationItemSelectedListener(this)
      NavigationUI.setupActionBarWithNavController(this,navController,appBarConfiguration)
  
  
  }
  
  
  
  
  
  
  override fun onCreateOptionsMenu(menu: Menu): Boolean {
      menuInflater.inflate(R.menu.navigation, menu)
      return true
  }
  
  
  
  
  
  override fun onSupportNavigateUp(): Boolean {
      val navHostFragment =
          supportFragmentManager.findFragmentById(R.id.fragmentactivatedformain) as NavHostFragment
      val navController = navHostFragment.navController
      return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
  }
  
  
  
  
  override fun onOptionsItemSelected(item: MenuItem): Boolean {
  
      when(item.itemId){
          R.id.profilePage-&gt; {
              Log.e(&quot;NAV&quot;,&quot;nav selected working&quot;)
              binding.root.findNavController().navigate(R.id.profilePage)
              return true
          }
          else-&gt;
          {
              return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
  
      }
      }
  
    // return item.onNavDestinationSelected(navController) ||  super.onOptionsItemSelected(item)
  
     }
  
  override fun onNavigationItemSelected(item: MenuItem): Boolean {
      Log.e(&quot;NAV&quot;,&quot;nav selected working2&quot;)
      return true
  }
  }
  </code></pre>
  <p>This is the  layout file  for my activity main page</p>
  <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
  &lt;androidx.drawerlayout.widget.DrawerLayout
  android:id=&quot;@+id/drawer_layout&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  android:fitsSystemWindows=&quot;true&quot;
  tools:openDrawer=&quot;start&quot;
  tools:context=&quot;com.nads.epicureapp.MainActivity&quot;&gt;
  &lt;com.google.android.material.navigation.NavigationView
      android:id=&quot;@+id/nav_view&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_gravity=&quot;start&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;@+id/linearLayout&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;
      app:headerLayout=&quot;@layout/nav_header_menu&quot;
      app:menu=&quot;@menu/nav_drawer_menu&quot; /&gt;
  &lt;LinearLayout
      android:id=&quot;@+id/linearLayout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;&gt;
      &lt;androidx.appcompat.widget.Toolbar
          android:id=&quot;@+id/toolbar&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?attr/actionBarSize&quot;
          android:background=&quot;?attr/colorPrimary&quot;
          android:elevation=&quot;4dp&quot;
          android:theme=&quot;@style/ThemeOverlay.AppCompat.ActionBar&quot;
          app:popupTheme=&quot;@style/AppTheme.PopupOverlay&quot; /&gt;
      &lt;fragment
          android:id=&quot;@+id/fragmentactivatedformain&quot;
          android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_marginTop=&quot;16dp&quot;
          app:defaultNavHost=&quot;true&quot;
          app:navGraph=&quot;@navigation/userprimary_navigation&quot; /&gt;
       &lt;/LinearLayout&gt;
   &lt;/androidx.drawerlayout.widget.DrawerLayout&gt;
    &lt;/layout&gt;
  </code></pre>
  <p>this is my menu items in for navigationview drawerlayout where the profile page id is same as the id of in my navigation graph</p>
  <pre><code>   &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
     &lt;group android:id=&quot;@+id/primary&quot;&gt;
      &lt;item
          android:id=&quot;@+id/profilePage&quot;
          android:icon=&quot;@drawable/profileicon&quot;
          android:title=&quot;@string/userprofile&quot; /&gt;
    &lt;/group&gt;
     &lt;item
      android:id=&quot;@+id/settings_dest&quot;
      android:icon=&quot;@drawable/ic_app_settings&quot;
      android:title=&quot;@string/settings&quot; /&gt;
  
     &lt;/menu&gt;
  </code></pre>
  <p>this is my navgraph which i use to navigate to the profile page in this navigation graph</p>
  <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
   &lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:id=&quot;@+id/userprimary_navigation&quot;
  app:startDestination=&quot;@id/homeFragment&quot;&gt;
  
  
  &lt;fragment
      android:id=&quot;@+id/homeFragment&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.HomeFragment&quot;
      android:label=&quot;Epicure App&quot;
      tools:layout=&quot;@layout/fragment_home&quot; &gt;
      &lt;action
          android:id=&quot;@+id/action_homeFragment_to_searchFoods&quot;
          app:destination=&quot;@id/searchFoods&quot; /&gt;
      &lt;action
          android:id=&quot;@+id/action_homeFragment_to_searchCooks&quot;
          app:destination=&quot;@id/searchCooks&quot; /&gt;
     &lt;/fragment&gt;
     &lt;fragment
      android:id=&quot;@+id/cooksPage&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.CooksPage&quot;
      android:label=&quot;Cooks Page&quot;
      tools:layout=&quot;@layout/fragment_cooks_page&quot; /&gt;
      &lt;fragment
      android:id=&quot;@+id/searchFoods&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.SearchFoods&quot;
      android:label=&quot;Serch foods&quot;
      tools:layout=&quot;@layout/fragment_search_foods&quot; &gt;
      &lt;action
          android:id=&quot;@+id/action_searchFoods_to_foodDetails&quot;
          app:destination=&quot;@id/foodDetails&quot; /&gt;
     &lt;/fragment&gt;
     &lt;fragment
      android:id=&quot;@+id/searchCooks&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.SearchCooks&quot;
      android:label=&quot;Serch Cooks&quot;
      tools:layout=&quot;@layout/fragment_search_cooks&quot; &gt;
      &lt;action
          android:id=&quot;@+id/action_searchCooks_to_cooksPage&quot;
          app:destination=&quot;@id/cooksPage&quot; /&gt;
      &lt;/fragment&gt;
      &lt;fragment
      android:id=&quot;@+id/addRecipes&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.AddRecipes&quot;
      android:label=&quot;Add Recipes&quot;
      tools:layout=&quot;@layout/fragment_add_recipes&quot; /&gt;
      &lt;fragment
      android:id=&quot;@+id/settings_dest&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.Settings&quot;
      android:label=&quot;Settings&quot;
      tools:layout=&quot;@layout/fragment_settings&quot; /&gt;
      &lt;fragment
      android:id=&quot;@+id/foodDetails&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.FoodDetails&quot;
      android:label=&quot;fragment_food_details&quot;
      tools:layout=&quot;@layout/fragment_food_details&quot; /&gt;
      &lt;fragment
      android:id=&quot;@+id/profilePage&quot;
      android:name=&quot;com.nads.epicureapp.ui.homepage.ProfilePage&quot;
      android:label=&quot;fragment_profile_page&quot;
      tools:layout=&quot;@layout/fragment_profile_page&quot; /&gt;
      &lt;/navigation&gt;
  </code></pre>