Пример #1
0
 private void setListener() {
   resideMenu.addMenuInfo(info);
   itemGuanZhangEmail.setOnClickListener(this);
   itemGrRenXinXi.setOnClickListener(this);
   itemZhuangban.setOnClickListener(this);
   itemShoucang.setOnClickListener(this);
   itemXiangce.setOnClickListener(this);
   itemFile.setOnClickListener(this);
   info.setOnClickListener(this);
 }
 /* (non-Javadoc)
  * @see android.view.View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
  */
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   if (mResideMenu != null && mResideMenu.isOpened()) {
     return;
   }
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
   int pos = info.position;
   menu.clear();
   menu.setHeaderTitle("选项:");
   String filePath = (String) mAdapter.getItem(pos);
   ListMenuClickListener mListMenuClickListener =
       new ListMenuClickListener(mContext, filePath, mFileType);
   menu.add(0, AppUtils.MENU_DELETE, 0, "删除").setOnMenuItemClickListener(mListMenuClickListener);
   menu.add(0, AppUtils.MENU_SHOW, 0, "查看").setOnMenuItemClickListener(mListMenuClickListener);
 }
Пример #3
0
  // 监听手机上的BACK键
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      // 判断菜单是否关闭
      if (is_closed) {
        // 判断两次点击的时间间隔(默认设置为2秒)
        if ((System.currentTimeMillis() - mExitTime) > 2000) {
          Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();

          mExitTime = System.currentTimeMillis();
        } else {
          finish();
          System.exit(0);
          super.onBackPressed();
        }
      } else {
        resideMenu.closeMenu();
      }
      return true;
    }
    return super.onKeyDown(keyCode, event);
  }
Пример #4
0
  private void setUpMenu() {

    rg = (RadioGroup) findViewById(R.id.rg);
    rb1 = (RadioButton) findViewById(R.id.rb1);
    rb2 = (RadioButton) findViewById(R.id.rb2);
    rb3 = (RadioButton) findViewById(R.id.rb3);
    rb4 = (RadioButton) findViewById(R.id.rb4);
    rb5 = (RadioButton) findViewById(R.id.rb5);
    rg.setOnCheckedChangeListener(this);
    rb2.setChecked(true);
    // attach to current activity;
    resideMenu = new ResideMenu(this);
    resideMenu.setBackground(R.drawable.menu_background);
    resideMenu.attachToActivity(this);
    resideMenu.setMenuListener(menuListener);
    // valid scale factor is between 0.0f and 1.0f. leftmenu'width is
    // 150dip.
    resideMenu.setScaleValue(0.6f);
    // disable right menu
    resideMenu.setSwipeDirectionDisable(ResideMenu.DIRECTION_RIGHT);

    // create menu items;
    itemGuanZhangEmail = new ResideMenuItem(this, R.drawable.icon_profile, "馆长信箱");
    itemGrRenXinXi = new ResideMenuItem(this, R.string.MenuyInfo);
    itemZhuangban = new ResideMenuItem(this, R.string.Menudqck);
    itemShoucang = new ResideMenuItem(this, R.string.MenuJyjl);
    itemXiangce = new ResideMenuItem(this, "预约查询");
    itemFile = new ResideMenuItem(this, "违章查询");

    resideMenu.addMenuItem(itemGuanZhangEmail, ResideMenu.DIRECTION_LEFT);
    resideMenu.addMenuItem(itemGrRenXinXi, ResideMenu.DIRECTION_LEFT);
    resideMenu.addMenuItem(itemZhuangban, ResideMenu.DIRECTION_LEFT);
    resideMenu.addMenuItem(itemShoucang, ResideMenu.DIRECTION_LEFT);
    resideMenu.addMenuItem(itemXiangce, ResideMenu.DIRECTION_LEFT);
    resideMenu.addMenuItem(itemFile, ResideMenu.DIRECTION_LEFT);
    // 姓名和学号
    info = new ResideMenuInfo(this, R.drawable.icon_profile, "我我我", "2012012147");
  }
Пример #5
0
 @Override
 public boolean dispatchTouchEvent(MotionEvent ev) {
   return resideMenu.dispatchTouchEvent(ev);
 }
Пример #6
0
 // 点击按钮显示左边侧滑栏
 public void onClickLiftMenu(View v) {
   resideMenu.openMenu(ResideMenu.DIRECTION_LEFT);
 }