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 and their details on the same event details page. How can I do this?
Code:
public class Event
{
public final String name;
public final String title;
public final String details;
public Event(final String a_name,
final String a_title,
final String a_details)
{
name = a_name;
title = a_title;
details = a_details;
}
};
final Event e = eventDetails(1, 4);
name.setText(e.name);
title.setText(e.title);
details.setText(e.details);
//event details
public Event eventDetails(int m, int d) {
switch (m) {
case 1:
if (d == 10) {
return new Event("event1", "my-title1", "mydetails1");
}
if (d == 28) {
return new Event("event2", "my-title1", "mydetails1");
return new Event("event3", "my-title2", "mydetails2"); //add another event on this date; obviously this is not the right way.
}
break;
}
return new Event("default_my-name2", "default_my-title2", "default_mydetails2");
}
To store the events returned by eventDetails, you would do something like this:
Then to access the Events stored in ArrayList e:
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: