When button pressed want to visible the password otherwise it should be hidden or say dotted. I have Applied the following code but its not working. Any help would be appreciated.
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(button.isPressed()) {
upass.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
return true;
}
return true;
}
});
You have used
OnTouchListenerwhich gives youMotionEvent's. Use them! No need to check the button is pressed again as long as you are pressing itMotionEventis there.To visible a password field with with the password :
inputType = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORDWhen the button is pressed
MotionEvent.ACTION_UPSo you can visible the text. WhenMotionEvent.ACTION_DOWNkeep it as it was at the beginning.