{"action":"created","issue":{"url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/682","labels_url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/682/labels{/name}","comments_url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/682/comments","events_url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/682/events","html_url":"https://github.com/mikepenz/MaterialDrawer/issues/682","id":107873968,"number":682,"title":"How do I disable the Navigation Drawer when inside fragments?","user":{"login":"ovestoerholt","id":1399287,"avatar_url":"https://avatars.githubusercontent.com/u/1399287?v=3","gravatar_id":"","url":"https://api.github.com/users/ovestoerholt","html_url":"https://github.com/ovestoerholt","followers_url":"https://api.github.com/users/ovestoerholt/followers","following_url":"https://api.github.com/users/ovestoerholt/following{/other_user}","gists_url":"https://api.github.com/users/ovestoerholt/gists{/gist_id}","starred_url":"https://api.github.com/users/ovestoerholt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ovestoerholt/subscriptions","organizations_url":"https://api.github.com/users/ovestoerholt/orgs","repos_url":"https://api.github.com/users/ovestoerholt/repos","events_url":"https://api.github.com/users/ovestoerholt/events{/privacy}","received_events_url":"https://api.github.com/users/ovestoerholt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-23T08:44:03Z","updated_at":"2015-09-23T09:33:04Z","closed_at":null,"body":"I have implemented the drawer in an AppCompatActivity implementing OnBackStackChangedListener for fragment support, like this:\r\n\r\n    public class ReceiptActivity extends AppCompatActivity implements OnBackStackChangedListener {\r\n\r\n    // The drawer\r\n    private Drawer result = null;\r\n    FragmentManager fm = null;\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_receipt);\r\n\r\n        // Handle Toolbar\r\n        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);\r\n        setSupportActionBar(toolbar);\r\n\r\n        // Need to attach the omBackStackChangedListener to the activity\r\n        fm = getSupportFragmentManager();\r\n        fm.addOnBackStackChangedListener(this);\r\n\r\n        //Create the drawer\r\n        result = new DrawerBuilder()\r\n                .withActivity(this)\r\n                .withToolbar(toolbar)\r\n                .addDrawerItems(\r\n                        new PrimaryDrawerItem()\r\n                                .withName(R.string.drawer_example_list)\r\n                                .withIdentifier(1),\r\n                ) // add the items we want to use with our Drawer\r\n                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {\r\n                    @Override\r\n                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {\r\n                        // do something with the clicked item :D\r\n                        if (drawerItem != null) {\r\n\r\n                            FragmentTransaction ft = fm.beginTransaction();\r\n\r\n                            switch (drawerItem.getIdentifier()) {\r\n                                case 1:\r\n                                    ExampleList exampleList = new ExampleList();\r\n                                    ft.replace(R.id.frame_container, exampleList);\r\n                                    break;\r\n\r\n                            }\r\n                            ft.commit();\r\n\r\n                        }\r\n                        return false;\r\n                    }\r\n                })\r\n                .build();\r\n    }\r\n\r\n\r\nI also have a method for OnBackPressed() as recommended:\r\n\r\n    @Override\r\n    public void onBackPressed() {\r\n        if (result != null && result.isDrawerOpen()) {\r\n            result.closeDrawer();\r\n        } else {\r\n            super.onBackPressed();\r\n        }\r\n    }\r\n\r\nand the needed methods to implement the OnBackStackChangedListener.\r\n\r\n    /**\r\n     * Required call back for OnBackStackChangedListener\r\n     */\r\n    @Override\r\n    public void onBackStackChanged() {\r\n        Log.i(\"ReceiptActivity\", \"Backstack changed\");\r\n        shouldDisplayHomeUp();\r\n        }\r\n\r\n\r\n    public void shouldDisplayHomeUp(){\r\n        //Enable Up button if there are entries in the back stack\r\n        boolean canback = getSupportFragmentManager().getBackStackEntryCount() > 0;\r\n        if (canback) {\r\n            result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);\r\n            getSupportActionBar().setDisplayHomeAsUpEnabled(true);\r\n        } else {\r\n            getSupportActionBar().setDisplayHomeAsUpEnabled(false);\r\n            result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public boolean onSupportNavigateUp() {\r\n        //This method is called when the up button is pressed. Just the pop back stack.\r\n        getSupportFragmentManager().popBackStack();\r\n        return true;\r\n    }\r\n\r\nThis works very well. inside an 'elevated' fragment the arrow is shown. On base level the hamburger is shown.\r\n\r\nWhat I cannot get my head around is that when in an 'elevated' fragment (and the arrow is shown) if I press the arrow the navigation drawer is displayed instead of popping the fragment off the stack and bring me back to base level.\r\n\r\nAny suggestions is highly appreciated!\r\nBest regards from Ove"},"comment":{"url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/comments/142545353","html_url":"https://github.com/mikepenz/MaterialDrawer/issues/682#issuecomment-142545353","issue_url":"https://api.github.com/repos/mikepenz/MaterialDrawer/issues/682","id":142545353,"user":{"login":"ovestoerholt","id":1399287,"avatar_url":"https://avatars.githubusercontent.com/u/1399287?v=3","gravatar_id":"","url":"https://api.github.com/users/ovestoerholt","html_url":"https://github.com/ovestoerholt","followers_url":"https://api.github.com/users/ovestoerholt/followers","following_url":"https://api.github.com/users/ovestoerholt/following{/other_user}","gists_url":"https://api.github.com/users/ovestoerholt/gists{/gist_id}","starred_url":"https://api.github.com/users/ovestoerholt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ovestoerholt/subscriptions","organizations_url":"https://api.github.com/users/ovestoerholt/orgs","repos_url":"https://api.github.com/users/ovestoerholt/repos","events_url":"https://api.github.com/users/ovestoerholt/events{/privacy}","received_events_url":"https://api.github.com/users/ovestoerholt/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T09:33:04Z","updated_at":"2015-09-23T09:33:04Z","body":"Yes I have, and now I see what you mean! Thanks!"}}