@hmjd这里的答案帮助我设置了多个对象的文本。但是我现在遇到了一个问题。一个日期可以有多个事件,我想在同一个事件详细信息页面上显示所有事件及其详细信息。我怎样才能做到这一点?
代码:
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");
}