GestureDetector-onfling不执行
今天在做计算器的时候,遇到了一个问题,就是当我使用GestureDetector的时候,onFling方法不执行,而其他的可以执行。代码如下
@Override
public boolean onDown(MotionEvent arg0) {
android.util.Log.e("zhangshuli", "getx(down)===="+arg0.getX()+"getY(down)===="+arg0.getY());
myGestureSign = false;
return false;
} @Override
public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
/* Vanzo:zhangshuli on: Tue, 24 Mar 2015 20:52:05 +0000
* modify for v5 calculator
if (myGestureSign) {
return true;
}
if (Math.abs(arg0.getX() - arg1.getX()) > 120.0F) {
myGestureSign = true;
if (!mDrawerLayout.isDrawerVisible(GravityCompat.END)) {
mDrawerLayout.openDrawer(GravityCompat.END);
}
} else if (arg1.getX() - arg0.getX() > 120.0F) {
if (mDrawerLayout.isDrawerVisible(GravityCompat.END)) {
mDrawerLayout.closeDrawer(GravityCompat.END);
}
}
android.util.Log.e("zhangshuli", "arg0.getx(fling)===="+arg0.getX()+"getY(fling)===="+arg0.getY()+"arg1.getx(fling)===="+arg1.getX()+"arg1.getY(fling)===="+arg1.getY());
*/
// End of Vanzo: zhangshuli
return false;
}
后来在网上找到了原因,只要把onDown()的返回值更改成true就行了
如下
@Override
public boolean onDown(MotionEvent arg0) {
android.util.Log.e("zhangshuli", "getx(down)===="+arg0.getX()+"getY(down)===="+arg0.getY());
myGestureSign = false;
return true;
}
GestureDetector-onfling不执行的更多相关文章
- 札记:android手势识别,MotionEvent
摘要 本文是手势识别输入事件处理的完整学习记录.内容包括输入事件InputEvent响应方式,触摸事件MotionEvent的概念和使用,触摸事件的动作分类.多点触摸.根据案例和API分析了触摸手势T ...
- touch、touchevent-事件总结
1.废话不多说,直接上代码,如下 package com.example.mygestrue; import android.support.v7.app.ActionBarActivity; imp ...
- Bash 翻译
Bash参考手册 目录 1简介 1.1什么是Bash? 1.2什么是shell? 2定义 3基本外壳功能 3.1 Shell语法 3.1.1外壳操作 3.1.2报价 3.1.2.1逃逸角色 3.1.2 ...
- android GestureDetector 手势基础
1. 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing等等,我们知道View类有个View.OnTouchListener内部接口,通过重写他的onTouch(Vi ...
- 【Andorid------手势识别】GestureDetector和SimpleOnGestureListener的使用教程(转)——
FROM:http://www.cnblogs.com/transmuse/archive/2010/12/02/1894833.html 1. 当用户触摸屏幕的时候,会产生许多手势,例如down,u ...
- GestureDetector类及其用法
转载子:http://www.cnblogs.com/rayray/p/3422734.html 项目中有需求:针对一个imageview,点击需要查看大图,左右滑动能执行翻页. 自己对手势这一块并不 ...
- 手势识别 GestureDetector ScaleGestureDetector
识别器GestureDetector基本介绍 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing等.一般情况下,我们可以通过View或Activity的onTouch ...
- GestureDetector和SimpleOnGestureListener的使用教程
1. 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing等等,我们知道View类有个View.OnTouchListener内部接口,通过重写他的onTouch(Vi ...
- GestureDetector学习之左右滑动,上下滑动屏幕切换页面
要实现滑屏等触发事件,视情况而定: 如果实现的触屏或者手势效果较多,则使用第一种方法,实现OnGestureListener 接口(参考OnGestureListener): 如果只是实现较少的效果, ...
- Android L(5.0)源码之手势识别GestureDetector
本人新手,最近下了Android L的源码,正在研究手势识别,能力有限,现总结如下: Android识别触摸屏手势使得用户体验大大提高.在View类中有个View.OnTouchListener内部接 ...
随机推荐
- c#记录日志的方法
/// <summary> /// 生成日志 /// </summary> /// <param name="text"></param& ...
- Codefroces 852 G. Bathroom terminal
G. Bathroom terminal Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to p ...
- UVA Building designing
题目总结来说求一段序列,必须正负交替,且绝对值递增 #include <iostream> #include <cstdio> #include <cstring> ...
- Pycharm在Ubuntu14.04中的基本使用指南
前几天给大家分享了:如何在VMware虚拟机中安装Ubuntu14.04系统.今天给大家分享一下在Ubuntu14.04中如何简单的使用Pycharm.1.启动Pycharm,将进入Pycharm的启 ...
- Linux下QQ的使用并手动设置QQ文件保存路径
一.背景&&目标 马化腾迟迟不肯做linux版本的QQ和微信,实在抠脚. 没有办法,要在linux上使用QQ,目前我找到最好的办法就是使用wine,然而wine这个杀千刀的又是个坑货, ...
- Chrome OS 70 发布:这是安卓的私生子吗?
谷歌于28日正式宣布推出Chrome OS 70.这个最新的Chrome OS系统在一些设计上具备了更多安卓风味,为配备了触摸屏的Chromebook.平板电脑和二合一设备带来了操作界面改善. 据9t ...
- 今日SGU 5.14
//SGU 131 还没完全想清楚 留坑 SGU 259 题意:一个机器处理n个任务,每个任务有时间t和传送时间l 收获:贪心 #include<bits/stdc++.h> #defin ...
- <c:if test=""></c:if> 使用
1.页面引用<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 2.整形判 ...
- 【Henu ACM Round#14 A】Vitaly and Night
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 连续两个如果不全是0就递增cnt [代码] #include <bits/stdc++.h> using namespa ...
- [Python] Understand List Comprehensions in Python
List comprehensions provide a concise way to create new lists, where each item is the result of an o ...