在Android的触摸释放方法 [英] Touch Release method in Android

查看:152
本文介绍了在Android的触摸释放方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图捕捉TouchRelease事件的Andr​​oid。我已经看到,event.getAction()返回操作类型。但里面的的onTouchEvent它总是给行动ACTION_DOWN。你知道如何捕捉触摸RELASE事件。

 公共布尔的onTouchEvent(MotionEvent事件){
        Log.d(TAG,+ event.getAction());
        返回super.onTouchEvent(事件);
    }
 

解决方案

ACTION_UP :<一href="http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_UP">http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_UP

 查看视图=新的View();

view.setOnTouchListener(新OnTouchListener(){
  公共布尔onTouch(查看视图,MotionEvent事件){
    如果(event.getAction()== android.view.MotionEvent.ACTION_DOWN){
      Log.d(TouchTest,降落);
    }否则,如果(event.getAction()== android.view.MotionEvent.ACTION_UP){
      Log.d(TouchTest,润色);
    }
  }
}
 

I'm trying to capture the TouchRelease event in Android. I have seen that event.getAction() returns the action type. But inside "onTouchEvent" it always gives the action "ACTION_DOWN". Do you know how to capture the touch relase event.

public boolean onTouchEvent(MotionEvent event) {
        Log.d(TAG,""+event.getAction());
        return super.onTouchEvent(event);
    }

解决方案

You have ACTION_UP: http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_UP

View view = new View();

view.setOnTouchListener(new OnTouchListener () {
  public boolean onTouch(View view, MotionEvent event) {
    if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
      Log.d("TouchTest", "Touch down");
    } else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
      Log.d("TouchTest", "Touch up");
    }
  }
}

这篇关于在Android的触摸释放方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆