我有一个问题,我的方法方法的onTouchEvent不会被调用
@Override
public boolean onTouchEvent(MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
是较新的调用。任何想法为什么是这样?我正在构建一个谷歌的api 4.0.3应用程序,并且我很喜欢为我的viewFliper启用swipe。但是,如果接触更新,它不能工作。
BTW:
public class MainActivity extends SherlockMapActivity implements ActionBar.TabListener {
这就是我的活动的声明。并检测刷我已经实现:
SimpleOnGestureListener simpleOnGestureListener = new SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {
float sensitvity = 50;
if((e1.getX() - e2.getX()) > sensitvity){
SwipeLeft();
}else if((e2.getX() - e1.getX()) > sensitvity){
SwipeRight();
}
return true;
}
};
GestureDetector gestureDetector= new GestureDetector(simpleOnGestureListener);
谢谢你!
编辑:
的main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ViewFlipper
android:id="@+id/ViewFlipper"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<include
android:layout_height="match_parent"
layout="@layout/mymain" />
<include layout="@layout/secondmain" />
<include layout="@layout/thirdmain" />
<include layout="@layout/fourthmain" />
</ViewFlipper>
</LinearLayout>
EDIT2:我所有的包含的布局都实行滚动型是有可能,滚动采取的事件和处理它们。如何检测手势?
好吧,现在我确定问题是scrollview句柄触及,所以无论如何忽略这一点,但是滚动可用? – gabrjan