Kartik Prabhu
Kartik Prabhu

Reputation: 411

How to Display Dates in Calendar View from Database

I needed help with this. How do I display dates in Android CalendarView widget? I have MySQL database with dates, and I can query it with PHP and get JSON data from that. The problem I am having is how do I display these dates in CalendarView? And do I do it so when it is clicked, it takes me to new activity that corresponds to the date that is clicked?

Upvotes: 0

Views: 1807

Answers (1)

Md Abdul Gafur
Md Abdul Gafur

Reputation: 6201

Convert your database date to milliseconds then use this function.

http://developer.android.com/reference/android/widget/CalendarView.html#setDate%28long%29

then you can able to added click event by

calendarView.setOnDateChangeListener(new OnDateChangeListener() {

            @Override
            public void onSelectedDayChange(CalendarView view, int year, int month,
                    int dayOfMonth) {

**here you start new activity.**

            }
        });

thanks

Upvotes: 1

Related Questions