I'm trying to use the new Preference v14 Support library. To give the preferences a material style, I use the following style on my Activity:
<style name="PreferenceTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
That works fine. My problem is that when I add new Preferences at runtime, they get inflated using an old theme. Here's a screenshot of the result:
As you can see, the first preference, added via XML, has the new Material style, while the others don't.
Do you have any hint on how to solve the problem?
EDIT Here's an example of code I use to add the Preference at Runtime:
import android.support.v7.preference.ListPreference;
for (...) {
final ListPreference p = new ListPreference(getActivity());
p.setTitle(name);
p.setSummary(langname);
p.setEntryValues(langEntryValues);
p.setEntries(langDisplayValues);
p.setDialogTitle(R.string.select_language);
category.addPreference(p);
}
PS: The same behavior occurs with android.support.v7.preference.Preference