12

I'm pretty new to Android development and I'm looking for a means of including calendar in my Android application, but I'm striking out pretty bad when googling.

  1. Is there any way to use a default calendar kind of view in my application? (would be ideal since the UI would be familiar)

  2. Failing at a built-in option, are there any good libraries out there with a calendar control that I could use?

I'm not looking to sync and all of that (at least, at this point), just looking to have a calendar view that I can display information to the user.

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
Brian
  • 129
  • 1
  • 1
  • 3

8 Answers8

32

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

thomasdao
  • 2,927
  • 1
  • 28
  • 24
  • hey i used your calendar, and its awesome. but i need to set events on date. like i need to customize date colors according to event they have at that date. Can you give me a little idea how can i accomplish that? – Vikas Gupta May 17 '13 at 13:00
  • You can supply your own view for each cell based on the date, you can find it in the documentation https://github.com/roomorama/Caldroid#allow-customized-cell-for-the-dates-gridview You can find how to use it in the sample as well – thomasdao May 20 '13 at 03:36
  • I got stuck in this problem, can you please check? https://github.com/roomorama/Caldroid/issues/24 – Vikas Gupta Jun 05 '13 at 11:46
  • Yes I replied to ur issue – thomasdao Jun 09 '13 at 15:48
  • 4
    +1 for your good work – Tofeeq Ahmad Jul 12 '13 at 08:12
  • @VikasGupta Can you please tell me how you fetched all the events and displayed over to caldroid? – Cyph3rCod3r Mar 05 '14 at 10:24
  • Sir how to make single row (week view) calendar using Caldroid ? – Viks May 27 '15 at 07:47
  • Can you please check this issue - https://github.com/roomorama/Caldroid/issues/280 – A J Jun 14 '15 at 05:57
  • Great Job! Is there a possibility to dinamically color (highlight) certain arbitrary dates (in order to provide user with some app-specific info)? – Filip Feb 08 '16 at 10:27
  • Is this library supports vertical scrolling? – Vignesh Apr 25 '19 at 09:43
9

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

    enter image description here

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

OneWorld
  • 17,512
  • 21
  • 86
  • 136
  • "Indicators, highlighted dates (at least in this fork for android)" - is this also possible in Caldroid? I am in two minds whether to chose caldroid or this one, and I need higlighting dates... Thanks. – Filip Feb 08 '16 at 10:31
7

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.

Cristian
  • 198,401
  • 62
  • 356
  • 264
6

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.

Cfr
  • 5,092
  • 1
  • 33
  • 50
Simon Si
  • 61
  • 1
  • 1
  • Unfortunately this only works on API11 or later. It would be nice if someone created a good backport so you can support 2.x versions – THelper Jan 03 '13 at 14:50
2

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"
/>

enter image description here

Philippe
  • 1,567
  • 16
  • 18
  • Hi Philippe i m using above calender view.every working fine i need to set the calender year at 1990 how to do this?can you help me – Vinodh Kumar Jan 06 '17 at 06:48
2

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

Paul Chu
  • 1,249
  • 3
  • 19
  • 27
  • Did you successfully add the default calendar to your app? Please let me know. I need some help on this. Thanks – Adil Malik Jan 17 '13 at 18:24
1

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

1

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.

Mustafa Ferhan
  • 240
  • 2
  • 4