0
我正在通過startActivityForResult() 從圖庫加載圖像並在onActivity()中加載圖像。我無法實現該圖像的 touchlistener?供參考見下文。setOnTouchlistener爲圖像視圖
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == SELECT_PICTURE) {
......
......
Bitmap bitmapPreview = BitmapFactory.decodeFile(fileSrc); //load preview image
setimage.setImageBitmap(BitmapPreview);
setimage.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(getApplicationContext(), "Image touced!", Toast.LENGTH_SHORT).show();
return true;
}
});
類型View中的方法setOnTouchListener(View.OnTouchListener)不適用於參數(new OnTouchListener(){})我得到這個錯誤消息...任何想法? – jxgn 2012-02-28 14:01:39
@jxcn爲什麼你返回false,如果檢查它使用System.out.print(「圖像被觸摸」); – 2012-02-28 14:03:17
您是否有一個名爲OnTouchListener的自定義類型? – 2012-02-28 14:09:47