0

I have textview onclick of that a edittext dialog open which inputtype is password. but after click dialog ok button edittext value is setting on textview but in case of password it is showing any text on textview, any idea how to set hidden text(password) on textview in android?

2 Answers2

5

I think I understand what you're asking for... If this isn't right try to be more specific... your english is a bit difficult to understand.

I did this with a checkbox. You can bind your code to whatever... but this is the best way to do it (if it's what you're looking for)

if (isChecked) {
            // This will display plain-text
            edittextPassword
                    .setTransformationMethod(SingleLineTransformationMethod
                            .getInstance());
        } else {
            // This will display *******
            edittextPassword
                    .setTransformationMethod(PasswordTransformationMethod
                            .getInstance());
        }    
}
RyanInBinary
  • 1,533
  • 3
  • 19
  • 47
1

I'm not sure if I understand your question, but according to the title this sample should help you:

EditText pass = (EditText) findViewById(R.id.password);
pass.setTypeface(Typeface.DEFAULT);
View showPass = findViewById(R.id.show_pass_checkbox);
showPass.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
      String textValue = pass.getText().toString();
      if (((CheckBox) v).isChecked()) {
          pass.setText("");
          pass.setInputType(InputType.TYPE_CLASS_TEXT);
      }else {
          pass.setText    ("");
          pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
          pass.setTypeface(Typeface.DEFAULT);
      }
      pass.setText(textValue);
}});
Piotr Ślesarew
  • 2,826
  • 1
  • 17
  • 17