Search code examples
androiddatetimeandroid-calendarandroid-jsoncalendarview

How to display json response in android CalendarView?


I have a MaterialCalendarView in a android app and I have a json response like this:

{"Table":
[
{"userid":4,"eventname":"Aditya","eventdate":"\/Date(1479974400000-0800)\/","eventcolor":"5986FF","autoid":1011},
{"userid":4,"eventname":"dfgdgdgs","eventdate":"\/Date(1478678400000-0800)\/","eventcolor":"AD3D1F","autoid":1005},
{"userid":4,"eventname":"dfgdgdgs","eventdate":"\/Date(1478678400000-0800)\/","eventcolor":"AD3D1F","autoid":1006}
]
}

How to display this JSON response in my calendarView in their respective date?


Solution

  • For a fully feldged calender that scrolls horizonatlly u can use this lib: MaterialCalenderView

    use this lib to get a horrizontal calendar view .U can use decorators to show dots under dates and when u click on it , u can use a recylerview or something to list the events.

    Search for decorator you can use wth dates in that library.

    materialCalendarView.setDateTextAppearance()
    materialCalendarView.addDecorator(new OpenSansDecorator(getActivity())); 
    materialCalendarView.setHeaderTextAppearance(R.style.TextAppearance_ProfileCalenderHeader);
    materialCalendarView.setDateTextAppearance(R.style.TextAppearance_ProfileCalenderCurrentDate);           
    materialCalendarView.setWeekDayTextAppearance(R.style.TextAppearance_ProfileCalenderHeader);
    

    styles.xml

    <style name="TextAppearance.ProfileCalenderDate" parent="android:TextAppearance">
            <!--<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>-->
            <item name="android:textSize">@dimen/text_size_small</item>
            <item name="android:textColor">@drawable/calender_selection_drawable</item>
        </style>
    
        <style name="TextAppearance.ProfileCalenderCurrentDate" parent="android:TextAppearance">
            <!--<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>-->
            <item name="android:textSize">@dimen/text_size_small</item>
            <item name="android:textColor">@drawable/calendar_cur_slection_drawable</item>
        </style>