Android calendar view [closed]

≯℡__Kan透↙ 提交于 2019-12-17 10:59:24

问题


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.


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




回答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

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




回答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.




回答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.




回答5:


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




回答6:


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




回答7:


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




回答8:


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.



来源:https://stackoverflow.com/questions/3702998/android-calendar-view

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