구글 캘린더 API 사용해서 일정들을 받아와 앱에서 리스트뷰로 순서대로 출력해주려고 하는데요
막 여러 사람들꺼 짜짓기 하다가 너무 머리가 아퍼서 올려 봅니다...
모르겠는 부분은 ???로 처리해 놔서;; 고수님들께서 좀 돠 주셨으면 합니다...
이게 자바 소스구요
package com.holim.test;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarEventEntry;
import com.google.gdata.data.calendar.CalendarEventFeed;
import com.google.gdata.data.calendar.CalendarFeed;
import com.google.gdata.util.ServiceException;
public class MyFancyListView extends ListActivity {
TextView tv;
private ProgressDialog progressDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// String형을 data로 하는 ArrayAdapter 선언/초기화
// this: context to use
// R.layout.row: 한줄 한줄 표현할 item을 위한 view. 여기서는 \res\layout\row.xml 을 지정함.
// R.id.lable: 위 xml 문서에서 text를 담당할 요소(TextView)의 id.
// items: ListView에 표현될 data
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("계정", "비번");
try {
this.progressDialog = ProgressDialog.show(this, "Waiting Pls . . .", "upload data . . .");
URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed = ??????.myService.getFeed(feedUrl, CalendarFeed.class);
ArrayList<String> AllCalendars = new ArrayList<String>();
for(int i=0;i<resultFeed.getEntries().size();i++){
CalendarEntry entry = resultFeed.getEntries().get(i);
AllCalendars.add(entry.getTitle().getPlainText());
}
ArrayAdapter<String> AllCalendarsadapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, AllCalendars);
??????.setAdapter(AllCalendarsadapter);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
this.progressDialog = ProgressDialog.show(this, "Waiting Pls . . .", "upload data . . .");
URL feedUrl = new URL("https://www.google.com/calendar/feeds/"+??????????????+"/private/full");
CalendarEventFeed myFeed = ???????.myService.getFeed(feedUrl, CalendarEventFeed.class);
ArrayList<String> AllEvents = new ArrayList<String>();
for(int i=0;i<myFeed.getEntries().size();i++){
CalendarEventEntry entry = myFeed.getEntries().get(i);
AllEvents.add(entry.getTitle().getPlainText());
}
ArrayAdapter<String> AllEventsadapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, AllEvents);
?????.setAdapter(AllEventsadapter);
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*
ArrayAdapter<String> aa = new ArrayAdapter<String> (this,
R.layout.row,
R.id.label,
items);
// 위에 정의된 aa를 본 ListActivity의 아답터로 설정 */
tv = (TextView)findViewById(R.id.selection);
}
}
XML은 main과 row라는 파일 2개 만들었습니다 XML은 파일로 올려놓을깨요..
도와주세요 ㅠㅠ



