F0r3v3r-A-N00b F0r3v3r-A-N00b - 1 year ago 79
Android Question

View value of password edittext while a button is pressed

How can I view the value of an edittext view whose input type is "password" when i click a button and when i release the button, the text display goes back to unreadable format? Like what microsoft does in windows 8 when you click the "eye" that is next to a password field.


Answer Source
 yourButton.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {

               switch ( event.getAction() ) {
                case MotionEvent.ACTION_DOWN: 
                case MotionEvent.ACTION_UP: 
                    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                return true;