android - ListView/GridView 中按下项目的默认背景颜色

标签 android listview gridview background resources

我正在尝试制作一个可选择的 GridView。所以我需要默认颜色(当你点击项目时它应该保持选中状态)。我只需要按下项目的默认(浅蓝色)颜色(如 ListView 中的蓝色)。

view.setBackgroundResource(android.R.drawable.list_selector_background); 不起作用。

谢谢。

最佳答案

我相信这就是您要找的。 A very similar question has been asked here.

简而言之,这应该是您的答案:

It's list_selector_holo_dark or the equivalent holo light version; and these are the defaults in Honeycomb and above. list_selector_background is the non-holo version, used in Gingerbread and below.

为了清楚起见,我引用了/u/Espiandev。

关于android - ListView/GridView 中按下项目的默认背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15604231/

相关文章:

android - 检查 ListView 项目是否包含指定数据然后开始下一个 Activity

android - 如何使 ListView 一次滚动一行

android - Listview onitem点击数据进入arraylist

c# - PostBack 后在 GridView 中保留 DataSource

jquery - Telerik ASP .NET MVC Grid - 添加自定义删除按钮

c# - 如何在分组项目页面中每组之前插入图像列表?

java - 图像上的 if 语句

android - gradle构建后运行应用程序时出错

android - 当我使用 HILT 时 Workmanager 未启动

android - ListView 与 OnItemClickListener