android - 如何显示本地日历?

时间:2014-03-26 12:29:15

标签: android calendar android-calendar

我使用新的Calendar API,我想在我的应用程序中创建一个本地日历,用户可以在其上添加与应用程序相关的自定义事件。所以我已经能够通过它创建它这段代码:

/** Creates the values the new calendar will have */
        private static ContentValues buildNewCalContentValues() {
            final ContentValues cv = new ContentValues();
            cv.put(Calendars.ACCOUNT_NAME, ACCOUNT_NAME);
            cv.put(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL);
            cv.put(Calendars.NAME, CALENDAR_NAME);
            cv.put(Calendars.CALENDAR_DISPLAY_NAME, CALENDAR_NAME);
            cv.put(Calendars.CALENDAR_COLOR, 0xEA8561);
            // user can only read the calendar
            cv.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ);
            cv.put(Calendars.OWNER_ACCOUNT, ACCOUNT_NAME);
            cv.put(Calendars.VISIBLE, 1);
            cv.put(Calendars.SYNC_EVENTS, 1);
            return cv;
        }

        //Create and insert new calendar into android database

        public static void createCalendar(Context ctx) {
            ContentResolver cr = ctx.getContentResolver();
            final ContentValues cv = buildNewCalContentValues();
            Uri calUri = buildCalUri();
            // insert the calendar into the database
            cr.insert(calUri, cv);
        }

但问题是我不知道如何显示它并让用户与之互动。 有帮助吗?在此先感谢:)

0 个答案:

没有答案