I'm using ActionBarDrawerToggle
class to tie together the functionality of DrawerLayout
and the framework ActionBar
to implement the recommended design for navigation drawers.
What Android developer site says is:
Call syncState() from your Activity's onPostCreate to synchronize the indicator with the state of the linked DrawerLayout after onRestoreInstanceState has occurred.
But I'm not getting what syncState()
method actually does?
Please explain it as simple as possible.
The DrawerLayout
indicator is the little icon to the left of the ActionBar
home icon (see picture)
ActionBarDrawerToggle.syncState
is called properly offset this indicator based on whether or not the DrawerLayout
is open or closed after the instance state of the DrawerLayout
has been restored.
Call syncState()
from your activity's onPostCreate
to set the state of the indicator based on whether the drawerlayout is in open or closed state once the activity has been restored with onRestoreInstanceState
.
protected void onPostCreate(Bundle savedInstanceState) {
// TODO Display the navigation drawer icon on action bar when there state has changed
super.onPostCreate(savedInstanceState);
drawerListener.syncState();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With