안드로이드 개발 질문/답변
(글 수 45,052)
다음은 소스코드의 일부분입니다.
//test.m
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row);
//row.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"...
android:orientation="horizontal">
<TextView
android:id="@+id/list_header_title".../>
</LinearLayout>
위 코드는 adapter.getView() 수행시 error를 발생시킵니다. 허나 row.xml을 다음과 같이 수정하면
//row.xml
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_header_title".../>
error가 발생하지 않고 정상적으로 수행됩니다.
위의 경우 LinearLayout이 들어간것 뿐인데 왜 error가 발생하나요?
2011.05.16 18:35:43
E/AndroidRuntime( 908): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 908): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
위의 로그가 나옵니다. 꼭 TextView만 써서 해야하는건가요? LinearLayout으로 덮어서 사용할 수 없나요??



