【发布时间】:2011-10-21 12:12:35
【问题描述】:
是否可以检测到用户在按下按钮后将手指从按钮上移开的任何时间?
我已经确定当用户垂直离开按钮时 onTouchListener 将获得一个动作(它给出一个动作:ACTION_CANCEL),但我无法找到一种方法来确定用户何时水平离开按钮.
public boolean onTouch(View arg0, MotionEvent arg1) {
switch(arg1.getAction()){
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
switch(arg0.getId()){
case R.id.my_button:
button.setBackgroundResource(R.drawable.untouched);
break;
}
break;
case MotionEvent.ACTION_DOWN:
switch(arg0.getId()){
case R.id.my_button:
button.setBackgroundResource(R.drawable.touched);
break;
}
break;
}
return false;
}
【问题讨论】:
标签: android button ontouchlistener