gesture-imageview第三方库没有长点击事件的解决

通过给ImageView添加手势操作来解决


gestureDetector =new GestureDetector(new OnGestureListener() {

@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}

@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub

}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
// TODO Auto-generated method stub
return false;
}

@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
initDialog();
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
});




imageView.setOnTouchListener(new OnTouchListener() {


@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int a = event.getAction();


switch (a) {
case MotionEvent.ACTION_DOWN:
gestureDetector.onTouchEvent(event);
lastTime = System.currentTimeMillis();


System.out.println("action _dowm");
/*handler.post(new Runnable() {
public void run() {


try {
Thread.sleep(2000);
if (isMove) {
initDialog();
}

} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});*/


break;

case MotionEvent.ACTION_MOVE:
System.out.println("action _Move");
isMove=false ;

break;

case MotionEvent.ACTION_UP:
/*// System.out.println("action _up");
nextTime  =System.currentTimeMillis();
if (nextTime-lastTime >1000) {
initDialog();
}*/

}
return true;
}
});

上一篇:android 控件设置背景以后再代码中改变的时候对不其


下一篇:Toast自定义显示时长的解决方案