0
我ActionBarDrawerToggle初始化獲取onDrawerOpened和onDrawerClosed回調
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_opened, R.string.drawer_closed);
我ActionBarDrawerToggle初始化獲取onDrawerOpened和onDrawerClosed回調
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_opened, R.string.drawer_closed);
要獲得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);
歡迎堆棧溢出!你能提供一個更大的代碼示例嗎?更多細節將幫助我們回答你的問題。 – jkdev