0

I want to change the style of the Dialogs appearing in a PreferenceFragment.

My PreferenceFragment.java file:

public class PreferencesFragment extends PreferenceFragment  {

    public PreferencesFragment(){}

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_preferences, container, false);

        addPreferencesFromResource(R.xml.preferences);

        return rootView;
    }
}

the preferences.xml file:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <PreferenceCategory android:title="@string/preferences_category_general_title">

        <ListPreference
            android:defaultValue="en"
            android:entries="@array/preferences_languages"
            android:entryValues="@array/preferences_languages_values"
            android:key="language"
            android:title="@string/preferences_languages_title" />

    </PreferenceCategory>

</PreferenceScreen>

I want the dialog of a e.g. ListPreference look like this:

DialogPreference with custom Style

Currently they have the default Holo style, how do I change it? (I only want the custom title bar, the radio buttons aren't important)

MrWasdennnoch
  • 156
  • 1
  • 15

2 Answers2

1

Android handles the preference stuff on its own. However, you can extend ListPreference and override showDialog(Bundle b) method. Then you can show your custom dialog in there. For a sample see here

Pritam
  • 339
  • 3
  • 23
Brian
  • 1,318
  • 1
  • 16
  • 33
0

You can use onPrepareDialogBuilder method from the ListPrefrence.

HMM
  • 29
  • 1
  • 10
Pritam
  • 339
  • 3
  • 23