我有一个带有简单touchlistener的imageView,它在ACTION.UP上获取位图像素的颜色。
img.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event)
{
int action = event.getAction();
int x = (int) event.getX();
int y = (int) event.getY();
switch(action){
case MotionEvent.ACTION_UP:
int pixel = bitmap.getPixel(x, y);
if (pixel == Color.parseColor("#94e3f9")) {
Toast.makeText(MainActivity.this, "Blue Color", Toast.LENGTH_SHORT).show();
}
if (pixel == Color.parseColor("#f0c828")) {
Toast.makeText(MainActivity.this, "Yellow Color", Toast.LENGTH_SHORT).show();
}
if (pixel == Color.parseColor("#b3522c")) {
Toast.makeText(MainActivity.this, "Red Color", Toast.LENGTH_SHORT).show();
}
break;
}
return true;
}
});
与此同时,我希望能够在imageView中进行双击,并执行其他操作,例如打开对话框。
我如何实现和结合这个?