My TextView does not support the MotionEvent.Action_UP. I only get 0 on event.getAction.
But the same Code works perfekt for a ImageButton.
Doesn't a Textview support the MotionEvent.Action_UP?
textView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent event) {
Log.v("tag","textView"+event.getAction());
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Log.v("tag","textViewmousedown");
} else if(event.getAction() == MotionEvent.ACTION_UP) {
//This gets never called
Log.v("tag","textViewmouseup");
if (standardButtonClickListener != null) {
standardButtonClickListener.onStandardButtonClick(v);
}
}
return false;
}
});
It doesn't mean a gesture like swipe down it means that user touched the screen (finger down, the touch or gesture just started). Now you need to catch MotionEvent.ACTION_UP (finger up, gesture or touch ends here) and decide if there was a gesture you need. http://developer.android.com/training/gestures/detector.html.
Batching. For efficiency, motion events with ACTION_MOVE may batch together multiple movement samples within a single object. The most current pointer coordinates are available using getX(int) and getY(int) . Earlier coordinates within the batch are accessed using getHistoricalX(int, int) and getHistoricalY(int, int) .
Overview. Motion events describe movements in terms of an action code and a set of axis values. The action code specifies the state change that occurred such as a pointer going down or up. The axis values describe the position and other movement properties.
You have to return true
instead of false
in your onTouch
method. This way, further events will be delivered to your listener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With