我试图将多个听众添加到我的视图中。OnTouchListener 事件会被触发,但不会触发长按事件。有什么理由吗?我该如何解决?:)
这是我的来源:
bookFlipper.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v){ //not fired
Log.d(tag, "Long press invoked!");
//selectText();
return true;
}
});
bookFlipper.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event){
if(!menuShown && !selectionMode){
bookFlipper.onTouchEvent(event);
}
switch(event.getAction()){
case MotionEvent.ACTION_MOVE:
if(selectionMode){
}
return false;
case MotionEvent.ACTION_DOWN:
lastDownX = event.getX();
lastDownY = event.getX();
touchingBook = true;
break;
case MotionEvent.ACTION_UP:
touchingBook = false;
if(!selectionMode){
float diff = event.getX() / screenWidth;
float diffOld = lastDownX / screenWidth;
if(diff <= 0.33 && diffOld <= 0.33 && !menuShown){ // left
prevPage();
}else if(diff >= 0.66 && diffOld >= 0.66 && !menuShown){// right
nextPage();
}else if(diff < 0.66 && diff > 0.33 && diffOld < 0.66 && diffOld > 0.33){ // middle
showOverlay(!menuShown);
}
}
break;
default:
break;
}
return false;
}
});
谢谢 :)