示例#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();
  }
示例#2
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   mDrawerToggle.syncState();
 }