これは少し古いですが、将来同じ問題を抱えている人を助けることができます.
VideoView は、他の機能のために onClick/onLongClick を消費しているように見えます (十分に調査していません)。別の方法は、GestureDetectorCompat(compat) を使用して手動で行うことです(古いバージョンで動作するため)。
GestureDetectorCompat
GestureDetectorCompat gestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.OnGestureListener() {
@Override
public boolean onDown(MotionEvent motionEvent) {
/* Always return true, to indicate that the gestureDetectorCompat
* consumed the touch and can continue to the
* next gestures(long, single, etc..)
*/
return true;
}
@Override
public void onShowPress(MotionEvent motionEvent) {
}
@Override
public boolean onSingleTapUp(MotionEvent motionEvent) {
return false;
}
@Override
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
return false;
}
@Override
public void onLongPress(MotionEvent motionEvent) {
Log.i("SOME_TAG", "Longpress detected");
}
@Override
public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
return false;
}
});
onClick/onLongClick を実装するビュー。
意見
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// Return the result from GestureDetectorCompat so the view
// knows if the touch was consumes or not
return gestureDetectorCompat.onTouchEvent(motionEvent);
}
});