Elye
Elye

Reputation: 60081

How to show current value in EditTextPreference summary (like what ListPreference could do)?

I could list my current selected value using %s in the summary attribute of ListPreference

<ListPreference
        android:key="my_list_setting_key"
        android:title="Just title"
        android:summary="My current selected value: %s"
        android:dialogTitle="My title"
        android:entries="@array/my_list_setting_entries_key"
        android:entryValues="@array/my_list_setting_entries_value"
        android:defaultValue="default_value"/>

However for EditTextPreference, the below %s is not working.

<EditTextPreference
        android:key="my_text_setting_key"
        android:title="My title"
        android:summary="My current value : %s"
        android:dialogTitle="My title"
        android:defaultValue="default_value"/>

How could I list the current value in the EditTextPreference summary (or anywhere that is visible before opening up the dialog box)?

Upvotes: 2

Views: 81

Answers (1)

tadiuzzz
tadiuzzz

Reputation: 146

Add:app:useSimpleSummaryProvider="true" attribute to EditTextPreference

Upvotes: 1

Related Questions