Android navigation drawer setcheckable - android

Hello Greetings to everyone .I have Developed one app,in that app i have implemented navigation drawer and set
inside menu file
group android:checkableBehavior="single"
First menu is Home which is default.So the problem is that when i click on second or third menu it open respective fragment but when i press back button it r=open home fragment but in navigation drawer checkable item is last selected
On Back button last checkable item is checkable but it open home fragment

Related

How to get to the original Fragment from Bottom Navigation View?

I am facing a challenge in the app that i am developing.
I have a BottomNavigationView with 4 Fragments:
Home Feed Notification Profile
Home is the home fragment of my NAV GRAPH.
Lets suppose Home has a button and on click of it, it goes to CartFragment. Now i click to Feed by using BottomNavigationView. So now, when i click on home fragment again from BottomNavigation view...i see the CartFragment whereas i want to see the HomeFragment. And it doesn't even show the HomeFragment tab active on the bottomNavigationView, it is like it completely replaces it.
I am not able to switch to my original fragment whenever i click on a tab from BottomNavigationView
If you want to reset your backstack when you press one of the bottom nav items, use below code where you define bottom nav view and this will solve your problem:
yourBottomNavView.setOnItemSelectedListener { item ->
NavigationUI.onNavDestinationSelected(item, yourNavController)
yourNavController.popBackStack(item.itemId, inclusive = false)
true
}
Just change yourBottomNavView and yourNavController with yours.

How to set toolbar.setNavigationOnClickListener only for current fragment?

Started new project from navigation drawer activity template. By default, all drawer menu items are at the same navigation level. All fragments display hamburger menu button, that shows drawer.
I need to keep all items in drawer, but place Home as top level item and others as it's children like this:
Tried to overwrite toolbar?.setNavigationOnClickListener { } in Gallery fragment, but it also affects Home fragment and I didn't find how to restore default behavior.
How can I set Home as navigation parent for others or how to set navigation click listener to only one fragment?
For example you have set tag for every fragment to trace when you start new fragment and now check with Home and set click event..
Fragment home = getSupportFragmentManager().findFragmentByTag("home");

Categories in menu navigation drawer

How to implement menu navigation drawer, when user click some item of menu,menu list swipe to new menu list. All of this happen in menu navigation drawer.
There is the screen
It is when menu navigation drawer open
This is when user clicked second item
And finally when user clicked some item
You can use fragment with listView. when you click on a item, A new Fragment will override the screen. There you need to manage to show content.
you also need to store all fragment in a backstack, so you can go back to previous fragment.
Demo Link :- https://www.dropbox.com/s/i2eu2hl117t6v1x/main.rar?dl=0
APK Link :- https://www.dropbox.com/s/8h2zr8ah2dxgik3/app-debug.apk?dl=0

Change item checked in Navigation view

Navigation view example
In reference to the above example of NavigationView, say I have "Go to Second item" button in First item layout. If I click on "Go to Second item" button, I am successfully able to go to the Second item layout, but the checked item in NavigationView remains in First item. How do I change the checked state of a MenuItem from another class which extends Fragment. If I directly click on Second item from the Menu, then the checked state changes accordingly, but how to change checked state from another class which extends Fragment.
NavigationView tutorial: Tutorial and Android documentation.
Wrap your menu items with the tag group with attribute android:checkableBehavior="single"
Call NavigationView.setCheckedItem() when you click the button.

how to refresh tab bar when click slide menu category

I have an Action Bar with Fragment as follow. I would like to refresh current fragment using slide menu . i would like to change tab bar when click slide menu item. May I know how to get the current fragment and refresh the content.
after that i am select any category of slide menu
after that selecting category my fragment is refresh but my tab bar is still there so how to refresh my tab bar
Thanking You

Categories

Resources