我有一個日曆,如果用戶選擇日期並將其帶到事件詳細信息頁面。在事件詳細信息頁面上,數據以表格格式顯示。到現在爲止還挺好。問題是如何在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