Do I have to keep the fragment id's inside navigation graph as same as menu item id?

Viewed 141

I am trying to understand the code structure of default Navigation drawer created in android studio 3.6.3. In Navigation drawer when menu item is clicked it shows it corresponding fragment layout. I am trying to understand the mechanism. I have found that the navigation graph fragments id name and menu item id name are both same. I have first changed the menu item id name and called inside main activity using (R.id.menu_id). And when I launch the application the navigation menu were not functioning. Then I renamed the menu id name to as it was and changed the fragment's id name. But unfortunately after launching the app the menus didn't functioned. When I kept the both name same the menu works.

Inside (resource/navigation/mobile_navigation.xml). mobile_navigation.xml

Inside (resource/menu/activity_main_drawer.xml) activity_main_drawer.xml

Inside (java/MainActivity.java) MainActivity.java

Need someone guide on am I understanding wrong or not.

0 Answers
Related