Close Navigation Drawer On Application Start
I have developed an application with Navigation Drawer. Whenever the application starts for the first time, it has navigation drawer open. Is there any way I can set it as closed?
Solution 1:
There is a
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
change that code to the one of the followings
mUserLearnedDrawer = true;
or
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, true);
Or you can remove completely the logic of checking if the drawer is opened or not at the first time when the app runs and the related code to it (mUserLearnedDrawer variable and so on)
if (!mUserLearnedDrawer) {
// The user manually opened the drawer; store this flag to// prevent auto-showing// the navigation drawer automatically in the future.
mUserLearnedDrawer = true;
SharedPreferencessp= PreferenceManager
.getDefaultSharedPreferences(getActivity());
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true)
.commit();
}
Post a Comment for "Close Navigation Drawer On Application Start"