예제 #1
0
 @Override
 protected boolean onBackKeyPressed() {
   if (isShowingMenu) {
     mySlidingMenu.toggle();
     return true;
   }
   finish();
   return true;
 }
예제 #2
0
  private void initSlidingMenu() {
    menu = new MCSildingMenu();
    int width = getWindowManager().getDefaultDisplay().getWidth();
    width = (int) (width / 3.5);
    mySlidingMenu = new SlidingMenu(this);
    mySlidingMenu.setMode(SlidingMenu.LEFT);
    mySlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    mySlidingMenu.setBehindOffsetRes(R.dimen.com_margin);
    mySlidingMenu.setFadeDegree(0.42f);
    mySlidingMenu.setMenu(R.layout.frame_menu);
    mySlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    mySlidingMenu.setBackgroundResource(R.drawable.background_slidingmenu);
    mySlidingMenu.setBehindOffset(width);
    mySlidingMenu.setBehindCanvasTransformer(
        new SlidingMenu.CanvasTransformer() {
          @Override
          public void transformCanvas(Canvas canvas, float percentOpen) {
            // TODO Auto-generated method stub
            float scale = (float) (percentOpen * 0.25 + 0.75);
            canvas.scale(scale, scale, 0, canvas.getHeight() / 2);
          }
        });
    mySlidingMenu.setAboveCanvasTransformer(
        new SlidingMenu.CanvasTransformer() {

          @Override
          public void transformCanvas(Canvas canvas, float percentOpen) {
            // TODO Auto-generated method stub
            float scale = (float) (1 - percentOpen * 0.25);
            canvas.scale(scale, scale, 0, canvas.getHeight() / 2);
          }
        });
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, menu).commit();
    mySlidingMenu.setOnOpenedListener(
        new SlidingMenu.OnOpenedListener() {

          @Override
          public void onOpened() {
            // TODO Auto-generated method stub
            menu.callOnResumeForUpdate();
            menu.showData();
            isShowingMenu = true;
          }
        });
    mySlidingMenu.setOnCloseListener(
        new SlidingMenu.OnCloseListener() {

          @Override
          public void onClose() {
            // TODO Auto-generated method stub
            menu.callOnPauseForUpdate();
            hideKeyboard(mySlidingMenu);
            isShowingMenu = false;
          }
        });
  }
예제 #3
0
 @Override
 protected boolean onMenuKeyPressed() {
   mySlidingMenu.toggle();
   return true;
 }