atom-22
atom-22

Reputation: 199

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.

enter image description here

I need to keep all items in drawer, but place Home as top level item and others as it's children like this:

enter image description here

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?

Upvotes: 0

Views: 295

Answers (1)

MustafaShaikh
MustafaShaikh

Reputation: 152

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");

Upvotes: -1

Related Questions