有没有办法为软按钮获取onButtonDown或onButtonUp事件(即不是物理硬件按钮,而是屏幕上的按钮)?我在屏幕上有一个按钮,我希望用户按住X秒.为此,我需要分别捕获buttonDown和buttonUp事件.
谢谢,
布雷特
dra*_*ard 42
yourButton.setOnTouchListener( yourListener );
public boolean onTouch( View yourButton , MotionEvent theMotion ) {
switch ( theMotion.getAction() ) {
case MotionEvent.ACTION_DOWN: break;
case MotionEvent.ACTION_UP: break;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13656 次 |
| 最近记录: |