Close The Navigation Drawer In The Activity According To A Process In The Fragment?
I have an activity with a navigation drawer menu. I'm make close account process on one of the fragments of this activity. As a result of this process, I send the user to the dashboard. As a result of this, the user's access to the menu should be turned off.Thought that closing the click event of the menu icon would be a solution. I don't know how to do it. Or any other suggestions ?
Answer
If I get it right you want to disable access to drawer. To do so, you just need to disable button that opens it and lock it when closed. example:
btnMenu.isEnabled = false
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.START)
If you want to access drawer from a fragment, you can't and you don't need.
What you need is a method that performs all operations in your activity and then call this method from your fragment.
Example:
In Activity:
fun closeAndLockDrawer() {
drawer.closeDrawer(GravityCompat.START);
btnMenu.isEnabled = false
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.START)
}
In Fragment:
(activity as YourActivity).closeAndLockDrawer()
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View