我有一個圖像視圖,它可以拖拽並縮放,但現在我還需要在我的圖像視圖上放置setOnLongClickListner。我已經這樣做了,但它不起作用。但是當我禁用ontouch事件時,它開始工作。有誰可以告訴我如何解決這個問題。 這裏是我的代碼android setOnLongClickListner不能與onTouch事件一起工作
image.layout(0, 30, screenWidth, screenHeight - 30);
image.setScaleType(ImageView.ScaleType.FIT_XY);
params = new RelativeLayout.LayoutParams(screenWidth, screenHeight - 30);
params.leftMargin = 0;
params.topMargin = 30;
layout.addView(image, params);
image.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
Log.i("its working", "its working");
return true;
}
});
image.setOnTouchListener(this);
我,會是非常感激的。
非常感謝。
我們展示的代碼:當您設置監聽器,與ImageView的相關監聽器和裏面的任何代碼。另外,我認爲touch事件在onLongClick之前。可能onClickEvent並未被解僱,因爲它被onTouchListener使用。 – Maragues 2010-10-08 10:50:11