0

I have an imageView with a simple touchlistener which on ACTION.UP it get the color of the bitmap pixel.

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;
        }
    });

At the same time I want to have the ability of doubletap inside the imageView and do something else like opening a dialog box.

How I can implement and combine this?

0 Answers0