Action bar Back button not working

前端 未结 13 1814
再見小時候
再見小時候 2020-12-01 03:13

with the help of these Android Docs.I am trying to do a action bar Back button.I get an Action Bar Back Button like these below image:

13条回答
  •  佛祖请我去吃肉
    2020-12-01 04:09

    To me, I had to set mDrawerToggle.setToolbarNavigationClickListener(...) to a listener that triggers the back action. Otherwise it does nothing. This is what the source code of ActionBarDrawerToggle looks like:

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (mDrawerIndicatorEnabled) {
          toggle();
        } else if (mToolbarNavigationClickListener != null) {
          mToolbarNavigationClickListener.onClick(v);
        }
      }
    });
    

    So the default behaviour is actually to call our listener, and not do any magic on its own.

提交回复
热议问题