Hold the image and send it to the link in Android Studio

2

Hold the image and send it to the link in Android Studio I use an ImageView that when it clicks it performs a function, but I would like that when the image was pressed, another action was taken, which would be different than just a simple touch in the image. That is, the ImageView with 2 functions, 1 simple touch and the other of pressing the image. How do you create this function of pressing the image?

Thank you

    
asked by anonymous 14.09.2018 / 16:17

1 answer

1

For the simple touch, use the setOnClickListener method and to press use setOnLongClickListener .

Here's an example:

  imageView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getApplicationContext(), "LongClick! ", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Click! ", Toast.LENGTH_SHORT).show();
        }
    });
    
14.09.2018 / 18:05