2015-12-30 23 views
1

我要添加顏色的android日曆事件,我已經使用了下面的代碼如何爲android日曆事件添加顏色?

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); 

但這種代碼是不添加事件的顏色。即使我不能在日曆中添加事件時,我使用values.put(Events.DISPLAY_COLOR,0xffff0000)代碼。我如何實現Events.DISPLAY_COLOR?

+0

你可以試試'Color.parseColor (「0xffff0000」)? – pRaNaY

回答

2

使用Events.EVENT_COLOR代替Events.DISPLAY_COLOR

作爲參考試試,你可以使用這個linkCalendars

+0

感謝Jitendar,請注意我的問題中我更新的代碼,這也有相同的pblm,即使我不能在日曆中添加事件時,我使用values.put(Events.DISPLAY_COLOR,0xffff0000); –

+0

謝謝jitendar,它現在正在工作。非常感謝 –

0

工作,我達成的目標:

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