3

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();
Mridul S Kumar
  • 326
  • 1
  • 4
  • 20

2 Answers2

2

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.

mikepenz
  • 12,708
  • 14
  • 77
  • 117
0

You can check here. It is mentioned in doc that how you can handle header part and its events.

Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55