Materialdrawer: withStickyFooter() passes onclick event to backside of the drawer

Created on 23 Apr 2016  路  6Comments  路  Source: mikepenz/MaterialDrawer

Hi Mike,

I found clicking on the sticky footer passes the onclick event to backside of the drawer. It seems sticky footer doesn't exists on the drawer and the drawer doesn't exists! If you need proof let me know.

question

All 6 comments

@meNESS so the the item of the StickyDrawer doesn't react on the click?

@mikepenz Yes. The sticky drawer item doesn't react on the click.

@meNESS just tested it. It works on my side. You may post a small sample so I can reproduce your issue. Also it might help to provide the Android version you use?

@mikepenz

Tested on: Emulator API 23
Build tools version: 23.0.3
Android support library version: 23.3.0
MaterialDrawer version: 5.2.0

private void buildDrawer(Bundle savedInstanceState) {
 // create footer view
 ViewGroup drawerFooterView = (ViewGroup) getLayoutInflater().inflate(R.layout.drawer_footer, null, false);
 ((TextView) drawerFooterView.findViewById(R.id.footer)).setText(String.format(getString(R.string.app_drawer_footer), BuildConfig.VERSION_NAME));

 // create the AccountHeader
 AccountHeader accountHeader = new AccountHeaderBuilder()
  .withActivity(this)
  .withHeaderBackground(R.drawable.header)
  .withOnlyMainProfileImageVisible(true)
  .withCompactStyle(true)
  .withDividerBelowHeader(false)
  .withCurrentProfileHiddenInList(true)
  .addProfiles(
   new ProfileDrawerItem().withName("").withEmail("").withIcon(""),
   new ProfileSettingDrawerItem().withName(getString(R.string.manage_account)).withIcon(GoogleMaterial.Icon.gmd_settings).withIdentifier(1).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
    @Override
    public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
     openAccountSettingDialog();
     return false;
    }
   })
  )
  .withSavedInstance(savedInstanceState)
  .build();

 mDrawer = new DrawerBuilder(this)
  .addDrawerItems(
   new PrimaryDrawerItem().withName(R.string.home).withIdentifier(0).withIcon(GoogleMaterial.Icon.gmd_home),
   new PrimaryDrawerItem().withName(R.string.loved).withIdentifier(1).withIcon(GoogleMaterial.Icon.gmd_favorite),
   new PrimaryDrawerItem().withName(R.string.watched).withIdentifier(2).withIcon(GoogleMaterial.Icon.gmd_visibility),
   new DividerDrawerItem(),
   new SecondaryDrawerItem().withName(R.string.help).withIdentifier(3).withIcon(GoogleMaterial.Icon.gmd_help)
  )
  .withAccountHeader(accountHeader)
  .withStickyFooterShadow(false)
  .withStickyFooter(drawerFooterView)
  //FIXME first item wont be selected!
  .withSelectedItem(0)
  .withSavedInstance(savedInstanceState)
  .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
   @Override
   public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
    // change page current item while drawer item selection changed
    pager.setCurrentItem((int) iDrawerItem.getIdentifier());
    return false;
   }
  })
  .build();
}

ice_video_20160424-114323

@meNESS oh I see now. You have added an Footer which is not clickable. So it is without a click listener. And so it does not consume the click event. I expected yuo added a PrimaryDrawerItem or so.

Just define a OnClickListener on that view to consume the event. This will prevent android from passing the event to the views behind

@meNESS oh now I see what happens. I thought you have a StickyFooter with a normal DrawerItem which will then consume the event. In your case you provide a few which does not catch the event and so it is passed through to the behind view.

Just set clickable="true" on your layout. (the root of the drawer_footer)

Or you do it programatically:

drawerFooterView.setClickable(true);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Meeks91 picture Meeks91  路  3Comments

singhalavi picture singhalavi  路  4Comments

HanderWei picture HanderWei  路  3Comments

wayne1203 picture wayne1203  路  3Comments

GutoMartins019 picture GutoMartins019  路  4Comments