Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Get Color object from Resource

Tags:

android

Color color = new Color(context.getResources().getColor(R.color.bus_departures_hover));

As seen, I am attemping to create a Color object from a resource. This ain't working though!

like image 973
basickarl Avatar asked Mar 16 '23 21:03

basickarl


1 Answers

What has worked for me is:

Color c = new Color(ContextCompat.getColor(context, R.color.yourColor));
like image 122
Janx from Venezuela Avatar answered Mar 27 '23 13:03

Janx from Venezuela