Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MotionEvent.ACTION_UP on Textview

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;
                }
            });
like image 245
passsy Avatar asked Aug 03 '11 09:08

passsy


People also ask

What is Action_up and Action_down?

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.

What is MotionEvent Action_move?

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) .

What is a motion event?

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.


1 Answers

You have to return true instead of false in your onTouch method. This way, further events will be delivered to your listener.

like image 77
Felix Avatar answered Sep 23 '22 16:09

Felix