【发布时间】:2013-05-17 04:31:54
【问题描述】:
我正在使用数组适配器创建一个 listView。这是我的代码。
listView = new ListView(context);
ArrayAdapter<String>adapter = new ArrayAdapter<String>(context,android.R.layout.simple_list_item_single_choice, choice);
listView.setAdapter(adapter);
这为文本提供黑色。我需要将文本颜色更改为蓝色。我们怎样才能改变这一点。我将我的布局与阵列适配器一起使用。这是代码
listView = new ListView(context);
ArrayAdapter<String>adapter = new ArrayAdapter<String>(context,layout.my_single_choice, choice);
listView.setAdapter(adapter);
my_single_choice.xml 的代码如下所示
<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/my_choice_radio"
android:layout_height="match_parent"
android:button="@null"
android:drawableRight="@android:drawable/btn_radio"
android:text="Option"
style="@style/ListItemTextColor" />
这不起作用,我可以选择我所有的单选按钮。当 clickListener 不工作时,...?我们该如何解决它
【问题讨论】:
-
你试过 android:textColor 吗?
-
您应该为您的列表视图使用自定义适配器。我认为您可能需要复选框而不是单选按钮。stackoverflow.com/questions/16685366/…。并在 checkbox.xml 中添加 @blackbelt 告知的文本颜色
标签: android android-listview radio-button android-arrayadapter