本文介绍了简单的滑动手势来活动教程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
即时寻找与刷卡gesutes源$ C $ C一turoial,我不想一个视图寻呼机,我希望有一个滑动手势教程。这里有一个例子,我发现,但不工作对我来说
http://www.eridem.net/android-tip-010-left-and-right-swipe-gesture-events
我想是这样的,谢谢请没有查看传呼机
解决方案
SimpleOnGestureListener mySimpleGestureListener =新SimpleOnGestureListener()
{
@覆盖
公共布尔onDoubleTap(MotionEvent E){
Logout.debug(onDoubleTap);
返回super.onDoubleTap(E);
}
@覆盖
公共布尔onFling(MotionEvent E1,E2 MotionEvent,浮velocityX,浮动velocityY)
{
字符串速度=onFling:\ N+ e1.toString()+\ N+ e2.toString()+\ N
+velocityX =+将String.valueOf(velocityX)+\ N
+velocityY =+将String.valueOf(velocityY)+\ N的;
Logout.debug(onFling速度=+速度);
返回super.onFling(E1,E2,velocityX,velocityY);
}
@覆盖
公共无效onLong preSS(MotionEvent E){
Logout.debug(onLong preSS:\ N+ e.toString());
super.onLong preSS(E);
}
@覆盖
公共布尔onSingleTapConfirmed(MotionEvent E){
Logout.debug(onSingleTapConfirmed:\ N+ e.toString());
返回super.onSingleTapConfirmed(E);
}
私人布尔permissibleYVelocity(浮动velocityY)
{
如果((velocityY&所述; -200)||(velocityY&并在200))
{
返回false;
}
其他
{
返回true;
}
}
};
GestureDetector myGestureDetector =新GestureDetector(mSimpleOnGestureListener);
View.OnTouchListener mOnListTouchListener =新OnTouchListener()
{
@覆盖
公共布尔onTouch(查看视图,MotionEvent事件)
{
Logout.debug(名单onTouch());
返回myGestureDetector.onTouchEvent(事件);
}
};
im looking for a turoial with source code on swipe gesutes, I dont want a view pager, I want a swipe gesture tutorial.here is one example I found but doesnt work for me
http://www.eridem.net/android-tip-010-left-and-right-swipe-gesture-events
I would like something like this, thanksPlease no view pagers
解决方案
SimpleOnGestureListener mySimpleGestureListener = new SimpleOnGestureListener()
{
@Override
public boolean onDoubleTap(MotionEvent e) {
Logout.debug("onDoubleTap");
return super.onDoubleTap(e);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY)
{
String velocity="onFling: \n" + e1.toString() + "\n" + e2.toString() +"\n"
+ "velocityX= " + String.valueOf(velocityX) + "\n"
+ "velocityY= " + String.valueOf(velocityY) + "\n";
Logout.debug("onFling velocity="+velocity);
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public void onLongPress(MotionEvent e) {
Logout.debug("onLongPress: \n" + e.toString());
super.onLongPress(e);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
Logout.debug("onSingleTapConfirmed: \n" + e.toString());
return super.onSingleTapConfirmed(e);
}
private boolean permissibleYVelocity(float velocityY)
{
if ((velocityY < -200) || (velocityY > 200))
{
return false;
}
else
{
return true;
}
}
};
GestureDetector myGestureDetector = new GestureDetector(mSimpleOnGestureListener);
View.OnTouchListener mOnListTouchListener = new OnTouchListener()
{
@Override
public boolean onTouch(View view, MotionEvent event)
{
Logout.debug("list onTouch()");
return myGestureDetector.onTouchEvent(event);
}
};
这篇关于简单的滑动手势来活动教程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!