对话框首选项中的自定义视图

4
我该如何在扩展的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)...
    }
}

同时在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" />

例如,是否可以更改按钮的属性?

我有一个“确定”按钮,例如我想要更改此“确定”按钮的颜色,如何做到这一点?

2个回答

5

0

要设置DialogPreference的背景,您还可以使用以下方法

    DialogPreference.setDialogLayoutResource(R.layout.layout1);

还有简单的颜色资源,通常在res/values/colors.xml中指定:

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

在`res/layout/layout1.xml`中,通过`android:background="@color/red"`引用此资源。 (有关设置背景的更多信息

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接