gpt4 book ai didi

android - 如何更改列表 simple_list_item_multiple_choice 中的颜色

转载 作者:行者123 更新时间:2023-11-29 02:16:49 26 4
gpt4 key购买 nike

您好,我有一个带有 simple_list_item_multiple_choice 布局的列表。列表都是白色的,我的背景也是白色的,因此不可见。我该如何改变它的颜色?

谢谢,普雷纳

最佳答案

api 缺少这样的基本功能确实看起来很愚蠢,但我认为您的解决方案必须是定义您自己的 ListAdapter:

XML:

<android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#rrggbb"
/>

自定义列表 Activity :

public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter(this, R.layout.row, R.id.label, items));
}

如果您遇到基于列表项状态(禁用/选择/点击等)的问题,您必须将 android:listSelector 设置为自定义选择器,该选择器由以下内容组成StateListDrawable 的集合:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@drawable/item_disabled" />
<item android:state_pressed="true"
android:drawable="@drawable/item_pressed" />
</selector>

关于android - 如何更改列表 simple_list_item_multiple_choice 中的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3120754/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com