Exemplo n.º 1
0
  /** 初始化侧滑栏 */
  private void initDrawerLayout() {
    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.navdrawer);

    mDrawerArrow =
        new DrawerArrowDrawable(this) {
          @Override
          public boolean isLayoutRtl() {
            return false;
          }
        };
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, mDrawerArrow, R.string.drawer_open, R.string.drawer_close) {

          public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
            isOpen = false;
          }

          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
            isOpen = true;
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
  }
Exemplo n.º 2
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   mDrawerToggle.onConfigurationChanged(newConfig);
 }
Exemplo n.º 3
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   mDrawerToggle.syncState();
 }