이 블로그 검색

2011년 7월 17일 일요일

ListActivity 와 ListView

안드로이드 개발자 공식 사이트중 노트패드 튜토리얼을 보면서 따라하던중
http://developer.android.com/resources/tutorials/notepad/notepad-ex1.htm

컴파일을 해보고 돌려보니 처음 레이아웃을 불러오는 지점에서 프로그램이 죽었다. 왜 그러는지 열심히 삽을 들고 찾아보던 도중 튜토리얼에 나와있는 코드와 나의 코드를 비교해보니 이 부분이 틀렸다.

레이아웃을 설정하는 xml부분에서

튜토리얼:
  <ListView android:id="@android:id/list"
  android:id="@+id/list" 라고 사용한 것이 문제 였다.

공식 홈페이지에서 ListActivity 에 관하여 찾아보면 다음과 같은 글이 있다.

ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)

다음부터는 이런 뻘짓 하지 않기를 바라면서 이상 끝

댓글 없음:

댓글 쓰기