Home Ask Login Register

Developers Planet

Your answer is one click away!

user616076 February 2016

My EditTextPreference is not updaing after adding string to Dialog

I've added an EditTextPreference to my Settings.xml with the code below

        android:title="User Name"
        android:summary="Please add user name." />

When I run it the dialog box appears but when I add my name it doesn't update and still says 'Please add..' What have I left out?


Kamil Stachowiak February 2016

Please create Your own EditTextPreference. To achieve Your result You need to override getSummary method.

public class EditTextPreference extends android.preference.EditTextPreference{

    public EditTextPreference(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

    public EditTextPreference(Context context, AttributeSet attrs) {
        super(context, attrs);

    public EditTextPreference(Context context) {

    public CharSequence getSummary() {
        String summary = super.getSummary().toString();
        return String.format(summary, getText());

Then I use in preferences.xml file, newly created EditTextPreference, and in summary I set value from strings.xml like this:


And finally in strings.xml it looks like this:

Please select user. Currently set is: %s

Final summary is then: Please select user. Currently set is: selectedValue

Post Status

Asked in February 2016
Viewed 1,826 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life