且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的 - 开抽屉式导航栏点击应用程序图标?

更新时间:2022-12-29 08:36:19

我就遇到了这个问题还,假设你已经有一个ActionBarDrawerToggle为@Kernald建议,您还需要以下内容添加到您的活动:

I ran into this issue also, assuming you already have an ActionBarDrawerToggle as @Kernald suggested, you need to add the following also to your Activity:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Pass the event to ActionBarDrawerToggle, if it returns
    // true, then it has handled the app icon touch event
    if (mDrawerToggle.onOptionsItemSelected(item)) {
      return true;
    }
    // Handle your other action bar items...

    return super.onOptionsItemSelected(item);
}

这让我们拨动手柄上的动作条图标按钮preSS,造成抽屉滑出。

This let's the toggle handle the icon button press on the ActionBar, causing the Drawer to slide out.