You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added `shouldHandleMenuItem()`, which can be overridden to handle some menu items yourself in the listener set via `setNavigationItemSelectedListener()`.
Copy file name to clipboardExpand all lines: README.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,10 @@ Now you have your navigation drawer up and running, including state saving of th
49
49
50
50
# Advanced Usage
51
51
52
+
## OnNavigationItemSelectedListener
53
+
54
+
An additional `OnNavigationItemSelectedListener` can be provided via `setNavigationItemSelectedListener()`. This can be used to add behavior after the fragment transaction was commited. If you just want to close the drawer, the lib includes a `CloseDrawerNavigationItemSelectedListener`.
55
+
52
56
## Back Stack
53
57
54
58
There are cases when some menu items (e.g. settings) should not simply replace the current fragment, but also be added to the back stack. To do this, override `shouldAddToBackStack()` in your adapter:
@@ -58,28 +62,42 @@ There are cases when some menu items (e.g. settings) should not simply replace t
58
62
return menuItemId == R.id.navitem_settings;
59
63
}
60
64
61
-
## Animations
65
+
## Custom Actions
62
66
63
-
You can provide custom animations for your fragment transactions via `setCustomAnimations()`. Separate animations can be set for when you add the transaction to the back stack via `setBackStackCustomAnimations()`.
67
+
If you don't want to handle fragments when a menu item is selected (e.g. to start an Activity), you can override `shouldHandleMenuItem()` in your adapter:
64
68
65
-
## OnNavigationItemSelectedListener
69
+
@Override
70
+
public boolean shouldHandleMenuItem(@IdRes int menuItemId) {
An additional `OnNavigationItemSelectedListener` can be provided via `setNavigationItemSelectedListener()`. This can be used to add behavior after the fragment transaction was commited. If you just want to close the drawer, the lib includes a `CloseDrawerNavigationItemSelectedListener`.
74
+
Don't forget to set an additional `OnNavigationItemSelectedListener` via `setNavigationItemSelectedListener()`, where you have to handle these menu items:
You can provide custom animations for your fragment transactions via `setCustomAnimations()`. Separate animations can be set for when you add the transaction to the back stack via `setBackStackCustomAnimations()`.
68
90
69
91
# Sample
70
92
71
93
A basic sample app with example Activities for both adapters is available in the `sample` project.
thrownewIllegalStateException("You have to set a listener with setNavigationItemSelectedListener() when menu items should not be handled by the adapter");
thrownewIllegalStateException("You have to set a listener with setNavigationItemSelectedListener() when menu items should not be handled by the adapter");
0 commit comments