4

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?

gobernador
  • 5,659
  • 3
  • 32
  • 51
Lukap
  • 31,523
  • 64
  • 157
  • 244

2 Answers2

5

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

Community
  • 1
  • 1
arberg
  • 4,148
  • 4
  • 31
  • 39
0

To set background of DialogPreference you can also use method

    DialogPreference.setDialogLayoutResource(R.layout.layout1);

and simple color resources, specified usually inside res/values/colors.xml:

    <color name="red">#ffff0000</color>

Refer to this resource via android:background="@color/red" in res/layout/layout1.xml. (More info about setting a background)

Community
  • 1
  • 1
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259