1

I search about this, but didn't find an answer on on any sites. I'm curios about this one, because I implement onTouchListener and TextWatcher. And I'm having problem with EditText with drawable right for password (clickable drawable to show/hide password). I cannot write password on it.

I plan to put the onTouchListener inside the onClickListener but hesitate to do it, for the thought their will be conflict on Listeners.

My question is can I used them all at the same time the onClickListener , onTouchListener, and TextWatcher. For handling only just in case I need these Listeners.

I will just post my code, Here's my sample code for onTouchListener.

edtRegPassword.setOnTouchListener(new View.OnTouchListener() {
            @SuppressLint("ClickableViewAccessibility")
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                final int DRAWABLE_RIGHT = 2;
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    if (event.getX() >= (edtRegPassword.getRight() - edtRegPassword.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                        showPassword();
                    } else {
                        hidePassword();
                    }
                    return true;
                }
                return false;
            }
        });

NOTE: I removed the picture and some code. Already been answered.

RoCkDevstack
  • 3,517
  • 7
  • 34
  • 56

0 Answers0