如何在android中的警报对话框中设置单选按钮?

时间:2016-08-24 07:19:00

标签: android radio-button alertdialog

我想在对话框中更改单选按钮的文本颜色,以及其他属性。怎么做?

我用来在对话框中创建单选按钮的代码:

AlertDialog.Builder builder = new AlertDialog.Builder(this);            
builder.setSingleChoiceItems(someArray, -1, someListener);

我尝试了 新的ContextThemeWrapper(这个,R.style.AlertDialogCustom) ,它仅适用于对话框本身,不适用于嵌入式单选按钮(比如文字颜色)

AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));            
builder.setSingleChoiceItems(someArray, -1, someListener);

R.style.AlertDialogCustom 示例:(尝试了其他属性,无效)

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AlertDialogCustom" parent="@android:style/Theme.Dialog">
    <item name="android:textColor">@color/colorGray</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textColorAlertDialogListItem">@color/colorGray</item>
    <item name="android:radioButtonStyle">@style/RadioButton</item>
</style>
</resources>

0 个答案:

没有答案