Created
July 9, 2015 08:18
-
-
Save xakoul/975477318637174eba81 to your computer and use it in GitHub Desktop.
Method to describe drawable click and password switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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