Skip to content

Instantly share code, notes, and snippets.

@akoul889
Created July 9, 2015 08:18
Show Gist options
  • Save akoul889/975477318637174eba81 to your computer and use it in GitHub Desktop.
Save akoul889/975477318637174eba81 to your computer and use it in GitHub Desktop.
Method to describe drawable click and password switch
citrusPassEt.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
if (event.getAction() == MotionEvent.ACTION_UP) {
if (event.getRawX() >= (citrusPassEt.getRight() - citrusPassEt
.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
// your action here
if (citrusPassEt.getInputType() == InputType.TYPE_TEXT_VARIATION_PASSWORD
|| citrusPassEt.getInputType() == 129) {
citrusPassEt.setInputType(InputType.TYPE_CLASS_TEXT | InputType
.TYPE_TEXT_VARIATION_NORMAL);
} else {
citrusPassEt.setInputType(InputType.TYPE_CLASS_TEXT | InputType
.TYPE_TEXT_VARIATION_PASSWORD);
}
return true;
}
}
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment