juergen d juergen d - 3 months ago 8
Android Question

Android programically added ListPreference has missing title

In my

PreferenceFragment
I have a ListPreference that I add programically in my PreferenceScreen like this

ListPreference groupPref = new ListPreference(getActivity());
groupPref.setTitle("Aktuelle Gruppe");
groupPref.setKey("groupObjectId");
groupPref.setEntries(entries);
groupPref.setEntryValues(values);

PreferenceScreen screen = this.getPreferenceScreen();
screen.addPreference(groupPref);


This works generally and the Preference has a title in the list of preferences. But it has no title when the choosing dialog opens.

screenshot

How to make it show a title in that dialog?

Answer

Call setDialogTitle(). setTitle() sets the title in the row in the PreferenceScreen.

Comments