When you change orientation, the activity runs the onCreate again. It also creates/sets up the NavigationDrawerFragment.
So if we have previously selected the 2nd item in the list and change the configuration by changing orientation, the 2nd item will stay as selected. It will also show the relevant fragment for that item (when set up).
However if we change the fragment via a button, on one of the fragments within, and call onNavigationDraweItemSelected manually. The fragment shown will change but the selected item/position in the navigation drawer does not change.
Hence when you rotate, the visible fragment will be based on the selected item that has not changed.
So how can we change the selected item in the Navigation Drawer, from some other method.
When you change orientation, the activity runs the
onCreate
again. It also creates/sets up theNavigationDrawerFragment
.So if we have previously selected the 2nd item in the list and change the configuration by changing orientation, the 2nd item will stay as selected. It will also show the relevant fragment for that item (when set up).
However if we change the fragment via a button, on one of the fragments within, and call
onNavigationDraweItemSelected
manually. The fragment shown will change but the selected item/position in the navigation drawer does not change.Hence when you rotate, the visible fragment will be based on the selected item that has not changed.
So how can we change the selected item in the Navigation Drawer, from some other method.