Reputation: 22556
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
Upvotes: 2
Views: 2084
Reputation: 5028
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:
setBackgroundColor(0xff000000 + Integer.parseInt(data.get(position).calendar_color));
Upvotes: 4
Reputation: 30855
There was field in table from that you can get the Color of calendar. Using calendar URI you can get the color of and event here is the link for more details
http://developer.android.com/reference/android/provider/CalendarContract.Calendars.html
Update
Ok I have tried your color using same way it parse and display the color. It too light teal color if you increase first two digit or remove it you can get it
setBackgroundColor(Color.parseColor("#658980")); // removed alpha color
setBackgroundColor(Color.parseColor("#13658980"));
Upvotes: 0