简体   繁体   中英

cursor won't change in edittext

So I have an EditText, (two actually, but both have the same problem,) and I added an OnTouchListener. I need to know what EditText I'm working with for another method. The problem is, before adding the listener, if I clicked somewhere in the EditText, the cursor would update. Now the cursor won't update at all.

 editText.setOnTouchListener(new View.OnTouchListener() {
        @SuppressWarnings("UnusedAssignment")
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            EditText et = (EditText) v;
            et.requestFocus();
            return true;
        }
    });

In this case, it is best to return false in onTouch . This is because the return value specifies whether or not the listener consumes the event. Returning false should therefore allow the widget to respond to the touch event with its normal behaviour, in addition to whatever else you have specified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM