开发者

Android calendar view [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 7 years ago.

Improve this question

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开发者_JAVA百科 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.


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

    Android calendar view [closed]

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.


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

Android calendar view [closed]


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜