Android calendar view

51,110

Solution 1

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

Solution 2

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.

Solution 3

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.

Solution 4

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.

Solution 5

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

Share:
51,110
Admin
Author by

Admin

Updated on January 13, 2020

Comments

  • Admin
    Admin over 4 years

    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.

  • THelper
    THelper over 11 years
    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
  • Adil Malik
    Adil Malik over 11 years
    Did you successfully add the default calendar to your app? Please let me know. I need some help on this. Thanks
  • Vikas Gupta
    Vikas Gupta about 11 years
    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?
  • thomasdao
    thomasdao about 11 years
    You can supply your own view for each cell based on the date, you can find it in the documentation github.com/roomorama/… You can find how to use it in the sample as well
  • Vikas Gupta
    Vikas Gupta about 11 years
    I got stuck in this problem, can you please check? github.com/roomorama/Caldroid/issues/24
  • thomasdao
    thomasdao about 11 years
    Yes I replied to ur issue
  • Tofeeq Ahmad
    Tofeeq Ahmad almost 11 years
    +1 for your good work
  • deeJ
    deeJ almost 11 years
    Much appreciated. Thanks.
  • Dr. aNdRO
    Dr. aNdRO over 10 years
    @VikasGupta Can you please tell me how you fetched all the events and displayed over to caldroid?
  • Vikash Parajuli
    Vikash Parajuli about 9 years
    Sir how to make single row (week view) calendar using Caldroid ?
  • A J
    A J about 9 years
    Can you please check this issue - github.com/roomorama/Caldroid/issues/280
  • Filip
    Filip over 8 years
    Great Job! Is there a possibility to dinamically color (highlight) certain arbitrary dates (in order to provide user with some app-specific info)?
  • Filip
    Filip over 8 years
    "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.
  • Vinodh Kumar
    Vinodh Kumar over 7 years
    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
  • Vignesh
    Vignesh about 5 years
    Is this library supports vertical scrolling?