我试着给出卡片查看项目的背景颜色,当它们被点击时,颜色被设置,新的活动是开放的,但是后面按下卡片项目的背景颜色是不设置的。
if (!arrayListBusinessList.get ( position ).equals ( "" )){
holder.cardViewBusinessListItem.setCardBackgroundColor ( ContextCompat.getColor ( context,R.color.green ) );
lastVisited ( true,position );
}发布于 2022-09-08 04:53:51
尝试一下,您可以使用颜色代码或颜色目录路径。
holder.cardViewBusinessListItem.setBackgroundColor(Color.parseColor("#00FF00"));发布于 2022-09-08 05:57:06
卡片视图有很多问题。相反,您应该更改父视图的背景,即卡内视图。
<CardView>
<RelativeLayout> <-- change this view's background instead
<ABC.../>
<XYZ.../>
</RelativeLayout>
</CardView>https://stackoverflow.com/questions/73643264
复制相似问题