我有一个日历,如果用户选择日期并将其带到事件详细信息页面。在事件详细信息页面上,数据以表格格式显示。到现在为止还挺好。问题是如何在eventDetails函数中设置事件的细节并返回它们来设置文本。返回数组中的日历事件详细信息
代码:
//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;
}
弦乐holiday
只返回一个对象。我想获取名称,标题和详细信息,并为其设置相应的元素文本。我怎样才能做到这一点?我如何将名称,标题和细节添加为单独的对象,并将它们作为单独的对象返回以相应地设置文本?我将它们添加到数组?像每一个事件日期:
String holiday[] = {"name of the event", "title of the event", "details of the event"};
如果是这样,我怎么返回数组来设置文本?
非常感谢您! – input 2012-07-08 21:54:27
我想添加多个事件到一个日期?我会怎么做?类似于'返回新事件(“my-name1”,“my-title1”,“mydetails1”)返回新事件(“my-name2”,“my-title2”,“mydetails2”);'但这不是正确的方式。 – input 2012-07-11 13:30:12
@input,返回'List'。 'List events = new ArrayList (); events.add(new Event(....)); events.add(new Event(...));返回事件;' –
hmjd
2012-07-11 13:31:53