How can I parse color from Google event color code?
I got Google Calendar event like this
I printed my logcat in this format event title : calendar color code
01-12 14:46:40.190: E/(19626): ID : 22 : Happy birthday! : 16437605
01-12 14:46:40.190: E/(19626): ID : 23 : May Day : 13658980
01-12 14:46:40.190: E/(19626): ID : 24 : New Year's Day : 13658980
01-12 14:46:40.190: E/(19626): ID : 25 : Christmas Day : 13658980
I tried this like
holder.eventColor.setBackgroundColor(Color.parseColor("#"
+ data.get(position).calendar_color));
so 13658980 is in which format? I think it’s not in ARGB
The data.get(position).calendar_color is a string that you need to convert to integer.
It does not contain alpha so you also need to add 0xff000000, for more information about this, see How to set background color of a View
The correct code is: