lumoss lumoss - 15 days ago 9
Android Question

Android EditTextPreference disable Dialog

I want to disable(not show) the Dialog, when i click the EditTextPreference in a Preference Activity.

When i click the EditTextPreference, a pop up dialog show. Now i want to disable this. I try set an onclicklistener, but the dialog show same.

public class Settings extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
EditTextPreference userName=(EditTextPreference) findPreference("prefUsername");
userName.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {

return false;
}
}); ...


I try add this to the EditTextPreference: android:clickable="false", but nothing.

Answer

Disable it.

Use

android:enabled="false"

in XML. Or to disable in runtime,

userName.setEnabled(false);

Actually, if you do not want a dialog, you probably should use simple Preference instead of EditTextPreference.