b1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: //按下 break; case MotionEvent.ACTION_MOVE: //移动 break; case MotionEvent.ACTION_UP: //抬起 break; } return true; } });
按键监听
public boolean onKeyDown(int keyCode, KeyEvent event) { } public boolean onKeyUp(int keyCode, KeyEvent event) { }