关于android控件上手势的问题 本帖最后由 wu55uw 于 2012-05-17 09:49:08 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 class GVIntGestureListener implements OnGestureListener,OnTouchListener { private GestureDetector mGestureDetector; public GVIntGestureListener() { mGestureDetector = new GestureDetector(mLauncher,this); mGestureDetector.setIsLongpressEnabled(false); } public boolean onDown(MotionEvent e) { Log.i("Down","Down"); return false; } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { Log.i("onFling","onFling"); if(Math.abs(velocityX)>Math.abs(velocityY ) && mDragView==null && !mbIsDraging){ //当前滑动的子控件索引 int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY()); TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件 if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){ tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex); View item = getChildAt(FlingChildIndex - getFirstVisiblePosition()); mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE); //在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作 setEnabled(false); mbIsDraging = true; } } return true; } public void onLongPress(MotionEvent e) { Log.i("onLongPress","onLongPress"); } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.i("onScroll","distanceX"+distanceX+"distanceY"+distanceY); if(Math.abs(distanceX)>Math.abs(distanceY) && mDragView==null && !mbIsDraging){ //当前滑动的子控件索引 int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY()); TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件 if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){ tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex); ViewGroup item = (ViewGroup) getChildAt(FlingChildIndex - getFirstVisiblePosition()); mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE); //在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作 setEnabled(false); mbIsDraging = true; } } return false; } 无法进行异步处理。。。急急急 怎么用Android实现桌面的精灵? Android jpg exif信息 没有出错信息,不显示文本信息 如何修改系统语言? 菜鸟问题,在AndroidManifest.xml中添加Activity不成功。 android proguard混淆 proguard.cfg文件配置 android 一个小问题 开发android的小盆友们加我Q了,发我个SDK吧 具体如何判断是否非系统应用呢????求大神赐教。。。 求高手解答关于android的sufaceview传值问题 android play市场,我要发布apk应用,可是问什么描述里面不可以写中文?
private GestureDetector mGestureDetector;
public GVIntGestureListener() {
mGestureDetector = new GestureDetector(mLauncher,this);
mGestureDetector.setIsLongpressEnabled(false);
}
public boolean onDown(MotionEvent e) {
Log.i("Down","Down");
return false;
} public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
Log.i("onFling","onFling");
if(Math.abs(velocityX)>Math.abs(velocityY ) && mDragView==null && !mbIsDraging){
//当前滑动的子控件索引
int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY());
TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件
if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){
tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex);
View item = getChildAt(FlingChildIndex - getFirstVisiblePosition());
mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE);
//在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作
setEnabled(false);
mbIsDraging = true;
}
}
return true;
} public void onLongPress(MotionEvent e) {
Log.i("onLongPress","onLongPress");
} public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
Log.i("onScroll","distanceX"+distanceX+"distanceY"+distanceY);
if(Math.abs(distanceX)>Math.abs(distanceY) && mDragView==null && !mbIsDraging){
//当前滑动的子控件索引
int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY());
TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件
if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){
tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex);
ViewGroup item = (ViewGroup) getChildAt(FlingChildIndex - getFirstVisiblePosition());
mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE);
//在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作
setEnabled(false);
mbIsDraging = true;
}
}
return false;
}