日历事件UI android

时间:2016-07-04 12:55:46

标签: android user-interface calendar

我可以创建这样的事件:

 public void Mindencalendar(){
    ContentResolver cr = getActivity().getContentResolver();
    Calendar calendarEvent = Calendar.getInstance();
    long idk[] = new long[szam];
    idk[szam-1] = cu.addEventToCalender(cr,"a","b","c",5,calendarEvent.getTimeInMillis());
    szam++;
}

...

 public class CalendarUtils{
    Context context;
    final int IDF = 12;


    public static long addEventToCalender(ContentResolver cr, String title, String addInfo, String place, int status,
                                          long startDate) {

        String eventUriStr = "content://com.android.calendar/" + "events";
        ContentValues event = new ContentValues();


        event.put("calendar_id", 1);
        event.put("title", title);
        event.put("description", addInfo);
        event.put("eventLocation", place);
        event.put("eventTimezone", "UTC/GMT +2:00");
        long endDate = startDate + 1000 * 60 * 60;
        event.put("dtstart", startDate);
        event.put("dtend", endDate);
        event.put("eventStatus", status);
        event.put("hasAlarm", 1);


        Uri eventUri = cr.insert(Uri.parse(eventUriStr), event);
        long eventID = Long.parseLong(eventUri.getLastPathSegment());

        //context.startActivity(i);

        return eventID;
    }
}

现在它已经完美地写入了日历,但我还没有获得用户界面,但我认为它将打开基本安卓日历的用户界面。如果我想在没有Intent的情况下这样做,我必须创建自己的布局吗?

2 个答案:

答案 0 :(得分:1)

如果您不想激发将用户发送到日历应用程序的意图,则必须创建自己的布局。

答案 1 :(得分:0)

您可以使用Date Picker 这是example