Mridang Agarwalla Mridang Agarwalla - 1 year ago 95
Android Question

How can I mask the summary of an EditTextPreference when it is a masked password field?

I'm using an

attached to my
that shows the value of the preference in the summary. Here's what it looks like:

public boolean onPreferenceChange(Preference prePreference, Object objValue) {
if (prePreference instanceof EditTextPreference) {
//TODO: Check if password type and show chacraters
return true;

If the field is a masked password field, I'd like to show the default password mask characters in the the summary. Here's an example of a masked field:

android:title="@string/password" />

Answer Source

Something like:

EditText edit = ((EditTextPreference) prePreference).getEditText();
String pref = edit.getTransformationMethod().getTransformation(objValue.toString(), edit).toString();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download