我的活动延伸ListActivity
。我有一个SimpleAdapter
正在调整一个字符串数组到我的列表视图中。一切都很完美。但列表视图中的默认复选标记为绿色。我想改变它的颜色。有人有建议吗?谢谢。
ListView listview= getListView();
// listview.setChoiceMode(listview.CHOICE_MODE_NONE);
// listview.setChoiceMode(listview.CHOICE_MODE_MULTIPLE);
listview.setChoiceMode(listview.CHOICE_MODE_SINGLE);
//-- text filtering
listview.setTextFilterEnabled(true);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(HomeScreenActivity.this , android.R.layout.simple_list_item_checked,nameStringsArray);
setListAdapter(adapter);
答案 0 :(得分:0)
您可以尝试在XML ListView中设置它
android:listSelector="@color/yourcolor"
EDIT:
通过“复选标记”,我认为这是排。由于您使用的是单选模式,我认为该对象是RadioButton。如果您使用自己的自定义布局,则可以访问该按钮,这会更简单。但既然不是你需要定义自己的风格:
Is it possible to change the radio button icon in an android radio button group
答案 1 :(得分:0)
创建自定义行布局是您所需要的。
原因是:复选框图标样式是依赖于系统的属性,您在设备上看到它是绿色的,但在另一台设备上它会是浅蓝色或紫色,......
要自定义复选框图标,请将xml布局文件中复选框的@button属性设置为您想要的新图标。
答案 2 :(得分:0)
你可以改变颜色/形式,怎么样?
尝试使用btn_Start default system
:
android:checkMark="@android:drawable/btn_star"
看看你的代码,玩得开心
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/btn_star_big_off" />
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/btn_star_big_on" />
<item android:state_checked="true" android:state_window_focused="false"
android:state_enabled="false" android:drawable="@drawable/btn_star_big_on_disable" />
<item android:state_checked="false" android:state_window_focused="false"
android:state_enabled="false" android:drawable="@drawable/btn_star_big_off_disable" />
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/btn_star_big_on_pressed" />
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/btn_star_big_off_pressed" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/btn_star_big_on_selected" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/btn_star_big_off_selected" />
<item android:state_checked="true" android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/btn_star_big_on_disable_focused" />
<item android:state_checked="true" android:state_focused="false" android:state_enabled="false"
android:drawable="@drawable/btn_star_big_on_disable" />
<item android:state_checked="false" android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/btn_star_big_off_disable_focused" />
<item android:state_checked="false" android:state_focused="false" android:state_enabled="false"
android:drawable="@drawable/btn_star_big_off_disable" />
<item android:state_checked="false" android:drawable="@drawable/btn_star_big_off" />
<item android:state_checked="true" android:drawable="@drawable/btn_star_big_on" />
</selector>
答案 3 :(得分:0)
完全没有必要创建自定义复选标记以进行自定义。复选标记的空框架由主题中的android:textColorSecondary
属性设置。要修改选中的颜色,请使用colorAccent
属性值。
使用AppCompat主题的示例样式:
<style name="MyListViewActivity" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">@color/listView_item_text</item>
<item name="android:textColorSecondary">@color/checkmark_unchecked</item>
<item name="colorAccent">@color/checkmark_checked</item>
</style>