ListPreference更改对话框样式(单选按钮颜色) [英] ListPreference change dialog style (radio button color)
问题描述
ListPreference嘿,我正在使用PreferenceActivity,并使用ListPreference向其中添加了单选按钮.问题是listPreference使用它自己的对话框,该对话框具有蓝色单选按钮(棒棒糖上为绿色),我需要将其更改为橙色.我设法获得对话框并使用以下命令更改标题和分隔线的颜色:
ListPreferenceHey I'm using PreferenceActivity and added radio button to it using ListPreference. The problem is that listPreference uses it own dialog which has blue radio button (green on lollipop) and I need to change it to orange. I managed to get the dialog and change the headline and the divider color using the following:
listPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog dialog = (AlertDialog) listPreference.getDialog();
if (dialog != null) {
changeDialog(getApplicationContext(), dialog);
}
return true;
}});
public void changeDialog(Context context, final AlertDialog dialog) {
int titleViewId = dialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null);
TextView title = (TextView) dialog.findViewById(titleViewId);
title.setTextColor(context.getResources().getColor(R.color.orange));
}
因此,如果标题ID为"android:id/alertTitle",而分频器ID为"android:id/titleDivider",则单选按钮的ID是什么?
So if the title id is "android:id/alertTitle" and the divder id is "android:id/titleDivider", what is the id for the radio button?
推荐答案
做到这一点的正确方法是使用< item name =" colorAccent">您的颜色</item>
主题
The right way to do this is to use <item name="colorAccent">YOUR COLOR</item>
in a theme
这篇关于ListPreference更改对话框样式(单选按钮颜色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!