Reputation: 541
I was following this tutorial for creating agenda view calendar.
It is working fine but what i need to show are the events from the server.
From server it is showing only the last event, i tried putting mCalendarView.setDate(myEventDay.getCalendar());
within and outside the for loop but it had the same effect.
Calendar cal = Calendar. getInstance();
for (int i = 0; i < response.length(); i++) {
// Get current json object
JSONObject details = response.getJSONObject(i);
String dateTime = details.getString("date_from");
StringTokenizer tokens = new StringTokenizer(dateTime, "T");
String date = tokens.nextToken();
String time = tokens.nextToken();
Date mdate = parseDateToddMMyyyy(Date);
String event_title = details.getString("event_title");
String event_description = details.getString("event_description");
String locationName = details.getString("event_location");
String event_lat = details.getString("lat");
String event_long = details.getString("longi");
String eTime = details.getString("from_time");
myEventDay = new MyEventDay(cal, eTime,
R.drawable.ic_shape, event_title, event_description, "",
"",
"lat "+event_lat+ " long " ,LocationName);
myEventDay.setCalendar(cal);
myEventDay.setmNote(event_title);
myEventDay.setmTime(eTime);
myEventDay.setmDescription(event_description);
myEventDay.setmCategory("Category");
myEventDay.setmSubCat("Sub Category");
myEventDay.setmLocationName(locationName);
mCalendarView.setDate(myEventDay.getCalendar());
mEventDays.add(myEventDay);
cal.clone();
}
mCalendarView.setEvents(mEventDays);
} catch (JSONException e) {
e.printStackTrace();
} catch (OutOfDateRangeException e) {
e.printStackTrace();
}
}
Upvotes: 1
Views: 238
Reputation: 439
Maybe it's the problem with the cal.clone()
method. I don't think it does anything. Try cal = cal.clone()
or putting Calendar cal = Calendar. getInstance();
inside for loop.
Upvotes: 1