@hmjd의 답변 here을 사용하면 여러 개체의 텍스트를 설정할 수있었습니다. 하지만 지금 문제가 생겼어. 날짜에는 여러 개의 이벤트가있을 수 있으며 모든 이벤트와 세부 정보를 동일한 이벤트 세부 정보 페이지에 표시하고 싶습니다. 어떻게해야합니까?여러 캘린더 이벤트를 반환
코드 : eventDetails에 의해 반환 된 이벤트를 저장하려면
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");
}
는 ArrayList에에 이벤트를 추가하고 그에 따라 ArrayList에 내부의 각 이벤트를 처리? –
adchilds
@adchilds, 내가 그랬어. '// 이벤트 정보 공개 ArrayList를 eventDetails (INT의 m, INT의 d) { \t ArrayList를 이벤트 = 새로운 ArrayList를 (); 스위치 (m) { \t \t \t 경우 (d의 == 15) { \t \t \t \t events.add (새로운 이벤트 ("합니다 Event1", "EVENTTITLE", "event_Details")); \t \t \t \t events.add (새 이벤트 ("event2", "eventtitle", "event_Details"))); \t \t \t \t 반환 이벤트; \t \t \t} 브레이크; \t \t} }'event 이벤트가 = eventDetails (m, d);'오류 :'타입 불일치 : ArrayList to HijriEvents.Event' –
input
오류는 무엇이 잘못되었는지를 알려줍니다. EventDetails의 반환 유형 (이벤트 유형의 ArrayList를 반환)을 일반 이벤트에 저장하려고합니다. ArrayList를 Event에 저장할 수 없습니다. 또한 switch 문은 현재 제공하지 않는 코드를 제공합니다 (원래 코드에서는 괜찮습니다). 최종 이벤트 e 은 ArrayList 유형이어야합니다. 그런 다음 해당 ArrayList에서 각 이벤트를 추출 할 수 있습니다. – adchilds