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?
Asked
Active
Viewed 1,770 times
0
-
Convert your database date to milliseconds then use this function . http://developer.android.com/reference/android/widget/CalendarView.html#setDate%28long%29 – Md Abdul Gafur Dec 31 '14 at 04:38
-
Oh wow thanks man. Now how do I do so that when I click on it, it takes me to a new activity that shows fields from database on that date? – Kartik Prabhu Dec 31 '14 at 04:55
-
Also, can I set multiple dates? – Kartik Prabhu Dec 31 '14 at 04:59
1 Answers
1
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

Md Abdul Gafur
- 6,213
- 2
- 27
- 37
-
I think, you able to added many data by call same function many time. – Md Abdul Gafur Dec 31 '14 at 05:11
-
Also, how do you think I can do so that I don't need to make the method for many different days? Like how do I use only one? – Kartik Prabhu Dec 31 '14 at 05:12
-
Meaning, if the user clicks on any of the days, it takes them to a page, where it is then customized for the date he clicked on – Kartik Prabhu Dec 31 '14 at 05:13
-
-
Ok, very good. How do I do so that when I add an event, it changes the color of that? Can I use CalendarView? Or do I have to use some other class, such as ExtendedCalendarView? – Kartik Prabhu Dec 31 '14 at 17:36