我的ActionBarDrawerToggle初始化
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_opened, R.string.drawer_closed);
答案 0 :(得分:1)
要使用onDrawerOpened,onDrawerClosed和其他实用工具方法,你必须在你的活动中实现DrawerListener;
public class MyActivity extends AppCompatActivity implements DrawerListener {
@Override
public void onDrawerOpened(View arg0) {
}
@Override
public void onDrawerClosed(View arg0) {
}
@Override
public void onDrawerSlide(View arg0, float arg1) {
}
@Override
public void onDrawerStateChanged(int arg0) {
}
}
然后你必须添加这一行来注册监听器并接收回调:
actionBarDrawerToggle.addDrawerListener(this);