I'm using navigation drawer working fine, but it closing slowly after an item is pressed. This happens if next activity has a extra code in oncreate method otherwise working properly..
So please help to solve this
I'm using navigation drawer working fine, but it closing slowly after an item is pressed. This happens if next activity has a extra code in oncreate method otherwise working properly..
So please help to solve this
I just managed to solve the problem you're experiencing.
First of all i have to say that i'm working on Android Studio 1.1.0 generated NavigationDrawer project.
This is the method onCreateView() of the class NavigationDrawerFragment
When a Item is clicked the
callback will fire and then the ball pass to
method.
The "selectItem()" method hides the NavigationDrawer and, using a callback, it calls a method into the "MainActivity" class -onNavigationDrawerItemSelected()-, that start the transition to the selected fragment.
The animation stuttering/lag happens because the code tries to close the NavigationDrawer and to get the UI layout hardcore job done at the same time.
If you want to avoid the lag you have to choose what to do first.
In my own workaround i decided to:
This is my own solution:
Don't be confused by the code.
We moved the selectItem(pos) inside a callback that will be fired only then the Drawer is closed and then we force the Drawer to close so the magic may occur.
This solution work for me, hope to know if it works for you as well.
There is closeDrawer(View view) and closerDrawer(int gravity). On your item click .closeDrawer(Gravity.START);
work fines for me.They might be helpful you too.
in your
displayView()
you get the selected item from drawer so you can specify themDrawerLayout
gravity likeon your item click you have to close drawaer layout