通过给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;
}
});