last day (14 days later) » 

9:23 AM
1
A: I want to Close Navigation Drawer if and only if I click the Button

Mike M.You can do this by adding a DrawerListener to your DrawerLayout that locks the drawer in the desired state. Locking a drawer disables dragging, but it will still respond to the openDrawer() and closeDrawer() methods, so your Button will still work as expected. drawerLayout.addDrawerListener(new ...

 
error Error:(152, 21) error: cannot find symbol method addDrawerListener(<anonymous SimpleDrawerListener>)
 
You must be using an older version of the support library. You can either update it, or change that method to the deprecated setDrawerListener() method.
 
I will check it.
The Update is available. I will Update it and then Come to you.
When Click on Button The Drawer is Open And When I click on Button the Drawer is close Where I have to put this code.
 
Uh, what's the problem, exactly? I thought that's what you wanted. The drawer only opens/closes with the Button.
 
yes Open when click on Button and Close When Click again.
 
9:23 AM
I don't understand what you're saying. What isn't working?
 
In starting the Drawer is Close state. When I click on + Button is open and + plus is move that working Fine. But I click NavigationView area like it's view size and click on that place the Drawer is Close But I want it Open. And When I click On + Button again the Navigation Drawer is close that time.
 
Oh, you don't want the drawer to close after you select something in the NavigationView. In that case, you've got code that you haven't posted where you're calling closeDrawer() or closeFab(). It'll probably be in some sort of callback for the NavigationView.
 
I want to select something and perform some operation so Close Drawer when click on button. how to do that thing.
 
Remove the call to closeDrawer() or closeFab() that's doing that. As I said, you haven't posted the code that's causing that behavior, so I can't be any more specific than that.
 
so it is possible or not ?
 
9:23 AM
Of course it is, but I can't tell you exactly what to do without seeing the code that's closing the drawer. You have a comment at the end of your posted code that references the dispatchTouchEvent() method. Are you doing something there to close the drawer?
 
I update the code. This code is for OutSideClick of NavigationDrawer detect.
 
It's this line that's closing the drawer: this.closeFab(); Remove it if you don't want that to happen. Why are you overriding dispatchTouchEvent() anyway? It doesn't look like you're doing anything with isOutSideClicked.
 
now you better understand see my question I draw the Area . When i click on that area. Only that time I want to close Drawer else it will open.
 
Then remove the code you added from my answer, and just remove the this.closeFab(); line from your dispatchTouchEvent() method.
 
some improve is there but one little problem is there. When I click OutSide of Navigation Drawer area then Drawer is close but Button is not move to original Position because remove this line this.closeFab();.
 
9:23 AM
OK, if I'm understanding you correctly, put the this.closeFab(); line in the if (!(rect.contains((int) event.getX(), (int) event.getY()))) block. So, in the original code, just move it from the else to the if.
 
you are to close I try it. but in that method there is if else. see that code in question.see my update code.
 
I don't know what you're saying. Put the this.closeFab(); line right after isOutSideClicked = true;.
 
do that but Button can't move only Drawer is Close.
 
Why did you change the code like that? We're only moving one line. In the first dispatchTouchEvent() you posted, move this.closeFab(); from under isOutSideClicked = false; to under isOutSideClicked = true;.
 
i have update it see my question.
any update information or not. only little problem is there.
 
9:23 AM
OK, I don't know what you meant to do with that dispatchTouchEvent() override, but I don't think you've been implementing it correctly. Change View content = findViewById(R.id.drawer_layout); to View content = findViewById(R.id.navigation_view);
 

last day (14 days later) »