Android calendar view [closed]

99封情书 提交于 2019-11-27 14:05:59

I wrote Caldroid library (https://github.com/roomorama/Caldroid) that is simple to setup and have many features such as setup min/max date, disabled dates, select date range, swipe to change month, fully localized, support rotation properly etc. It's easy to customize the look and feel. Just to share if someone might find it useful :)

I tried android-CalendarView, Caldroid and later switched to android-times-square which has this improvements:

  • Much faster switching to other months due to vertical scrolling (no pagination which responds slow in Caldroid)
  • Indicators, highlighted dates (at least in this fork for android)
  • iOS version available with the same look and feel
  • looks cleaner than the android version because months are clearly separated

Just like Caldroid it is a part of a productive app.

AFAIK, there are no other way than implement your own calendar. So... what you would have to do is using a GridLayout with 7 columns and create a custom BaseAdapter to display data correctly.

Simon Si

Android now provides three ways to incorporate calendars in your app.

  1. Calendar view for picking dates and such.

  2. Calendar provider can be accessed to add and remove events from the OS calendar.

  3. Calendar intents allow you to provide a calendar without having to get extra permissions or deal with databases.

This library seems really nice and with a more modern UI (Material Design) :

https://github.com/prolificinteractive/material-calendarview

You just have to import it with gradle:

compile 'com.prolificinteractive:material-calendarview:1.4.0'

And add it in your layout:

<com.prolificinteractive.materialcalendarview.MaterialCalendarView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mcv_showOtherDates="all"
app:mcv_selectionColor="#00F"
/>

John

it is possible but not easy. http://jimblackler.net/blog/?p=151&cpage=2#comment-52767

and

private void InsertAppointment(String strTitle, String strDescription, String strEventLocation, long StartDateTime, long EndDateTime, boolean bAllDay, boolean bHasAlarm){
    int tAllday;
    int tHasAlarm;
    if (bAllDay = true){
        tAllday = 1;
    }
    else
        tAllday = 0;
    if (bHasAlarm = true){
        tHasAlarm = 1;
    }
    else
        tHasAlarm = 0;

    ContentValues event = new ContentValues();
    // Calendar in which you want to add Evenet
    event.put("calendar_id", CalId);                //CalId                                  
    event.put("title", strTitle);                                                           
    event.put("description", strDescription);                                  
    event.put("eventLocation", strEventLocation);                                                   
    event.put("dtstart", StartDateTime);                                                          
    event.put("dtend", EndDateTime );                  
    event.put("allDay", 0);                     
    event.put("hasAlarm", 0);                                                                  
    Uri eventsUri = Uri.parse("content://com.android.calendar/events");    
    // event is added
    getContentResolver().insert(eventsUri, event);

}

a quick search on content://com.android.calendar/calendars will help get you started. but I'm not finished mine yet I just can't get the data out yet. but it is possible

You can use the android calendar picker I have created, it is open source project and you can easily add it to your project.

https://github.com/sancarbar/Android-Calendar-Picker

You can use MFCalendarView: https://github.com/MustafaFerhan/MFCalendarView

set multiple events;

ArrayList<String> eventDays = new ArrayList<String>();
eventDays.add("2014-02-25");
eventDays.add(Util.getCurrentDate());

mf.setEvents(eventDays);

and handle with MFCalendarView's listener:

mf = (MFCalendarView) findViewById(R.id.mFCalendarView);
mf.setOnCalendarViewListener(new onMFCalendarViewListener() {

    @Override
        public void onDisplayedMonthChanged(int month, int year, String monthStr) {
            }

            @Override
            public void onDateChanged(String date) {
            }
    });

It's very simple.

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