Your content MUST have a ListView whose id attribute is 'android.R.id.list'
조회수 1220회
우선 XML 파일의 내용은 이렇습니다.
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list" >
</ListView>
소스코드
이건 액티비티 내용이구요.
public class ExampleActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlist);
}
}
다른건 아무것도 안했습니다. 근데 아래와 같은 에러가 발생합니다.
Your content must have a ListView whose id attribute is 'android.R.id.list'
심지어 xml에 android:id="@+id/list" 이렇게 작성까지 했는데 말이죠. 도대체 뭐가 문제인걸까요?
1 답변
-
ListView의 아이디를 아래처럼 수정해주세요.
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
ListActivity를 쓰시면 xml에 리스트뷰 아이디를 무조건 android:id="@android:id/list"이렇게 지어야합니다.
만약에 커스텀 리스트뷰를 만들고싶으시면 ListActivity를 상속받지마시고 그냥 Activity를 상속받으셔서 android 키워드 빼고 동일한 아이디를 주시면 됩니다.
댓글 입력