How to add color for android calendar events?

 ̄綄美尐妖づ 提交于 2020-01-14 04:04:15

问题


I want to add color for android calendar events, i have used the following code

ContentResolver cr = context.getContentResolver();
ContentValues values = new ContentValues();
values.put(Events.DTSTART, startMillis);
values.put(Events.DTEND, endMillis);
values.put(Events.TITLE, phNumber);
values.put(Events.DISPLAY_COLOR, 0xffff0000);
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "UTC");
Uri uri = cr.insert(Events.CONTENT_URI, values);

But this code is not added color for event. Even i'm not able to add event in calendar when i use values.put(Events.DISPLAY_COLOR, 0xffff0000) code. How can i implement Events.DISPLAY_COLOR?


回答1:


Try using Events.EVENT_COLOR instead of Events.DISPLAY_COLOR

As a reference, you can use this link to work with Calendars




回答2:


I reached the goal by:

event.put("eventColor", 0xffff0000);


来源:https://stackoverflow.com/questions/34523259/how-to-add-color-for-android-calendar-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!