在onKeyDown方法之后意外结束应用程序

时间:2011-12-10 19:58:59

标签: android listview view back

嗨,伙计们,我调用方法onKeyDown,我的应用程序关闭,但没有让我回复错误,这是我的代码:

public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_BACK) 
  {
      if (expList.getVisibility() == View.VISIBLE){
          expList.setVisibility(View.INVISIBLE);

      }else{
          //
      }

  }
  return super.onKeyDown(keyCode, event);
}

1 个答案:

答案 0 :(得分:1)

您的应用关闭,因为您调用方法“super.onKeyDown(keycode,event);”

尝试使用返回false,如下所示:


    public boolean onKeyDown(int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK) 
      {
          if (expList.getVisibility() == View.VISIBLE){
              expList.setVisibility(View.INVISIBLE);

          }else{
              //
          }

      }
      return false;
    }