Materialdrawer: Drawer not closing on onClick

Created on 15 Jun 2016  路  2Comments  路  Source: mikepenz/MaterialDrawer

final Drawer drawer = new DrawerBuilder()
                .withActivity(this)
                .withToolbar(toolbar)
                .withActionBarDrawerToggle(true)
                .withAccountHeader(headerResult)
                .withCloseOnClick(true)
                .addDrawerItems(
                        new PrimaryDrawerItem()
                                .withIcon(FontAwesome.Icon.faw_home)
                                .withName("Home")
                                .withIconColor(getResources().getColor(R.color.colorAccent))
                                .withIdentifier(0)
                                .withSelectable(false),
                        new PrimaryDrawerItem()
                                .withIcon(FontAwesome.Icon.faw_cogs)
                                .withName("Settings")
                                .withSelectable(false)
                                .withIconColor(getResources().getColor(R.color.colorAccent))
                                .withIdentifier(1),
                        new DividerDrawerItem(),
                        new PrimaryDrawerItem()
                                .withIcon(FontAwesome.Icon.faw_bullhorn)
                                .withName("Tell a Friend")
                                .withIconColor(getResources().getColor(R.color.colorAccent))
                                .withIdentifier(2)
                                .withSelectable(false),
                        new PrimaryDrawerItem()
                                .withIcon(FontAwesome.Icon.faw_user)
                                .withName("About")
                                .withSelectable(false)
                                .withIconColor(getResources().getColor(R.color.colorAccent))
                                .withIdentifier(3),
                        new PrimaryDrawerItem()
                                .withIcon(FontAwesome.Icon.faw_gift)
                                .withName("Donate")
                                .withSelectable(false)
                                .withIconColor(getResources().getColor(R.color.colorAccent))
                                .withIdentifier(4)
                )
                .withSelectedItem(-1)

This is my code even have done .withCloseOnClick(true) it is still not closing the drawer on item click

question

Most helpful comment

@mtwn105 do you have a clickListener? You should return false in the onClickListener, to state that you don't consume the event

All 2 comments

@mtwn105 do you have a clickListener? You should return false in the onClickListener, to state that you don't consume the event

got it! thanks @mikepenz

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wayne1203 picture wayne1203  路  3Comments

oleynikd picture oleynikd  路  4Comments

singhalavi picture singhalavi  路  4Comments

Meeks91 picture Meeks91  路  3Comments

jehad-suliman picture jehad-suliman  路  3Comments