Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mikepenz Material Drawer custom header

I am using a custom header in mikepenz material drawer. How can i get the onClick of the header. Can I use onDrawerItemClickListener to get the click event of the custom header ?

result = new DrawerBuilder()
                .withActivity(this)
                .withSelectedItem(-1)
                .withSliderBackgroundColorRes(R.color.white)
                .withToolbar(toolbar)
                .withStickyHeader(R.layout.nav_header)
                .withTranslucentStatusBar(true)
                .withDisplayBelowStatusBar(true)
                .addDrawerItems(
                       //Drawer Items
                ).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {


                })
                .build();
like image 887
Mridul S Kumar Avatar asked Feb 02 '26 00:02

Mridul S Kumar


1 Answers

If you have defined a header (so not the AccountHeader) you can get the reference to that view by calling the following after building the Drawer:

Drawer.getHeader()

It's very similar for the sticky header:

Drawer.getStickyHeader()

This will return you the view of the header, and allow you to set any listener you need.

like image 129
mikepenz Avatar answered Feb 03 '26 14:02

mikepenz