Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set background color of TableRow

I try to set the background color of a TableRow. Currently I have this in my XML file:

android:background="@color/buttonBackground" 

and i work great. But when it run

row.setBackgroundColor(R.color.red);

the row disappears. Can someone explain why that is?

like image 560
Martin Hansen Avatar asked Feb 24 '23 03:02

Martin Hansen


1 Answers

I believe you need to do:

Resources resource = context.getResources();
row.setBackgroundColor(resource.getColor(R.color.red)
like image 199
Swati Avatar answered Mar 03 '23 12:03

Swati