如何将视图样式看起来像ListView [重复]

时间:2021-02-27 21:45:58

Possible Duplicate:
Getting the Listview default clicked color, depending on the Device

可能重复:获取Listview默认单击颜色,具体取决于设备

I would like to style a View to behave like a ListView. It means that when I click on it, the background color changes. I can't do this by setting a custom color because each device has a different style for this component. Any ideas how can I do it? Is there any system style I can apply on it?

我想将View设置为像ListView一样。这意味着当我点击它时,背景颜色会发生变化。我无法通过设置自定义颜色来执行此操作,因为每个设备都具有此组件的不同样式。任何想法我该怎么办?我可以应用任何系统风格吗?

1 个解决方案

#1


0  

setBackground(res.getDrawable(android.R.drawable.list_selector_background));

#1


0  

setBackground(res.getDrawable(android.R.drawable.list_selector_background));