I have a calendar in which if the user selects the date and it takes him to an event details page. On the event details page the data is displayed in a tabular format. So far so good. The problem is how to set the details of the event in the eventDetails function and return them to set the text.
Code:
//get the data and split it
String[] dateAr = date_string.split("-|\\||\\(|\\)|\\s+");
m = Integer.parseInt(dateAr[6]);
d = Integer.parseInt(dateAr[3]);
y = Integer.parseInt(dateAr[8]);
name = (TextView) this.findViewById(R.id.name);
title = (TextView) this.findViewById(R.id.title);
details = (TextView) this.findViewById(R.id.details);
name.setText(name_details); //should get the info from the eventDetails method
title.setText(title_details); //should get the info from the eventDetails method
details.setText(event_details); //should get the info from the eventDetails method
//event details
public String eventDetails(int m, int d) {
String holiday = "";
switch (m) {
case 1:
if (d == 1) {
holiday = "Some event";
} else if (d == 10) {
holiday = "Some event";
}
break;
case 3:
if ((d == 11) || (d == 12)) {
holiday = "Some event";
}
break;
case 7:
if ((d == 1) && (d== 7)) {
holiday = "Some event";
}
break;
}
return holiday;
}
The String holiday returns only one object. I want to get the name, title and details and set the corresponding element’s text to it. How can I achieve this? How do I add the name, title and details as separate objects and return them as separate objects to set the text accordingly? DO I add them to an array? Something like for every event date:
String holiday[] = {"name of the event", "title of the event", "details of the event"};
If so, how do I return the array to set the text?
Create a
classthat contains these event details and return an instance of it. For example: