Textview上的MotionEvent.ACTION_UP

pas*_*ssy 7 android listener mouseevent textview

我的TextView不支持MotionEvent.Action_UP.我在event.getAction上只得到0.

但是相同的代码对于ImageButton来说是完美的.

Textview不支持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;
                }
            });
Run Code Online (Sandbox Code Playgroud)

Fel*_*lix 13

您必须返回true而不是false在您的onTouch方法中.这样,其他事件将传递给您的听众.