Close Navigation Drawer on application start

前端 未结 1 1110
栀梦
栀梦 2021-01-05 10:02

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 se

相关标签:
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;
                        SharedPreferences sp = PreferenceManager
                                .getDefaultSharedPreferences(getActivity());
                        sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true)
                                .commit();
                    }
    
    0 讨论(0)
提交回复
热议问题