Advertisement
obernardovieira

[Android] [CheckBox] Password to text and vice-versa

Oct 3rd, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. final EditText Your_EditText = (EditText)findViewById(R.id.your_edittext_id);
  2. final CheckBox Your_CheckBox = (CheckBox)findViewById(R.id.your_checkbox_id);
  3.  
  4. Your_CheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  5.     @Override
  6.     public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
  7.         if(b)
  8.             Your_EditText.setInputType(InputType.TYPE_CLASS_TEXT);
  9.         else
  10.             Your_EditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
  11.     }
  12. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement