Custom view in Dialog Preference

Lukap picture Lukap · Nov 14, 2011 · Viewed 9.9k times · Source

How can I set a customize the style in extended DialogPreference ?

public class AboutDialog extends DialogPreference {
    public AboutDialog(Context oContext, AttributeSet attrs)
    {
        super(oContext,attrs);
            //there is no such a thing like setBackground(int res_id)...
    }
}

and in the xml

<com.pak1.pak.About
    android:key="key" android:title="@string/preferences_about"
    android:dialogTitle="@string/preferences_about_title"
    android:dialogIcon="@drawable/app_icon" android:negativeButtonText="@null"
    android:positiveButtonText="@string/ok" />

or for example is it possible to change properties of the button ?

I have one ok button, and for example I want to change the color of this 'ok' button, how can I do this?

Answer

arberg picture arberg · Jan 11, 2012

You override onCreateDialogView, and return the layout.

See for instance this example by Matthew Wiggins for creating a custom DialogPreference.

http://android.hlidskialf.com/blog/code/android-seekbar-preference

or here at stackoverflow

Android SeekBarPreference