Skip to content Skip to sidebar Skip to footer

Return Multiple Calendar Events

The answer here by @hmjd helped me to set the text of multiple objects. But I have run into a problem now. A date can have multiple events and I would like to show all the events a

Solution 1:

To store the events returned by eventDetails, you would do something like this:

ArrayList<Event> e = new ArrayList<Event>();
e.add(eventDetails(1, 4)); // This adds one event to the ArrayList

Then to access the Events stored in ArrayList e:

Event one = e.get(0); // First Event in the ArrayList
Event two = e.get(1); // Second Event in the ArrayList
...
Event n = e.get(n); // nth Event in the ArrayList

If you want to make this dynamic instead of explicitly saying e.get(0), you would loop over the size of the ArrayList as follows:

for (int i = 0; i < e.size(); i++)
{
    Event ev = e.get(i);
    ev.doSomething();
    ev.doSomethingElse();
}

Post a Comment for "Return Multiple Calendar Events"