Button按鈕有三種操作狀態:按下,然後在鎖定在按鈕中滑動,然後鬆開。
可以用setOnTouchListener監聽。
bt1 = (Button)findViewById(R.id.bt1);
bt1.setOnTouchListener(new OnTouchListener() {
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 false;
}
});