Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我实现了一个 ListView 来显示书籍的文本。这样每段文字都是ListView中的一个item(TextView)。但是我不希望在它们集中或选择并单击它们时将它们彼此区分开来。所以,我用于<selector>ListView;但我可以自定义项目的背景!
<selector>
现在,如果我想自定义列表项的前景,如文本颜色,我该怎么办?
您可以为列表项创建自己的 xml 布局并将其放入适配器中。例如,SimpleAdapter构造函数看起来像这样:
SimpleAdapter
SimpleAdapter adapter = new SimpleAdapter(context, list, R.layout.your_item_style, from, to) // where "your_item_style" is name of xml file in layout folder of your app