I have this image in the xml (and others elements):
<ImageView
android:clickable="true"
android:onClick="imageClick"
android:id="@+id/Decena0"
android:layout_width="120dp"
android:layout_height="120dp"
tools:ignore="ContentDescription" />
I want to run the two next methods when I press on the image and I don’t lift my finger:
First:
public void imageClick(View view) {
//Implement image click function
Log.e("Example", "Imagen clickada");
}
Second:
@Override
public boolean onTouchEvent(MotionEvent event) {
//Coordenadas
int x = (int) event.getX();
int y = (int) event.getY();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE;
break;
case MotionEvent.ACTION_UP:
break;
}
return true;
}
How I can do it? Because if I press on the image and lift my finger on the image, only runs the first method (I understand it perfectly), but if I press on the image and I don’t lift a finger and move my finger, not running any method. If I click somewhere else where there is no image the second method work well.
Thanks for all
According to the documentation for onTouchEvent:
So, when your method returns
true, the other events won’t fire. If you want any click listeners to run also, try returningfalse.