1

I tried to give the background colour of card view item when they are clicked the colour are set the new activity are open but then back pressed the card item background colour are not set.

if (!arrayListBusinessList.get ( position ).equals ( "" )){
     holder.cardViewBusinessListItem.setCardBackgroundColor ( ContextCompat.getColor ( context,R.color.green ) );
                        lastVisited ( true,position );
}
Zain
  • 37,492
  • 7
  • 60
  • 84
  • Does this answer your question? [CardView background color always white](https://stackoverflow.com/questions/41552973/cardview-background-color-always-white) – abdo Salm Sep 08 '22 at 06:09

2 Answers2

0

Try this you can use both color code or color directory path

holder.cardViewBusinessListItem.setBackgroundColor(Color.parseColor("#00FF00"));
Hanif Shaikh
  • 500
  • 1
  • 10
0

Card view has a lot of problems. You should instead change the background of the parent view that is inside card view.

<CardView>
    <RelativeLayout> <-- change this view's background instead
        <ABC.../>
        <XYZ.../>
    </RelativeLayout>
</CardView>