2011-11-14 47 views
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" /> 

,或者例如是有可能改变该按钮的属性?

我有一个确定按钮,例如我想改变这个“确定”按钮的颜色,我该怎么做?

回答

0

要设置DialogPreference的背景,你也可以使用方法

DialogPreference.setDialogLayoutResource(R.layout.layout1); 

和简单的色彩资源,内部res/values/colors.xml通常规定:

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

请参阅此资源通过res/layout/layout1.xml中的android:background="@color/red"。 (More info about setting a background