안드로이드 개발 질문/답변
(글 수 45,052)
=======================================================
list.java
=======================================================
Cursor cursor = db.rawQuery("select _id,NAME,ADDR from address1 order by name", null);
startManagingCursor(cursor);
SimpleCursorAdapter Adapter = null;
Adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2,
cursor,
new String[] { "_id","NAME", "ADDR" },
new int[] { R.id.TextView01,R.id.TextView02,R.id.TextView03}
);
lv1.setAdapter(Adapter);
//lv1.setOnItemClickListener(listClick);
db.close();
=======================================================
03-23 05:00:08.588: ERROR/AndroidRuntime(936): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
위와 같은에러가 나는데..
궁금증?
1.아래 list.xml과 같이 xml을 구성해도 되나요? 아님
- ListView 와 TextView를 따로 xml로 만들어야 하나요?
2.address1 테이블에 _id를 분명 pk로 만들고
new String[] { "_id","NAME", "ADDR" },
new int[] { R.id.TextView01,R.id.TextView02,R.id.TextView03}
으로 넣으는데 에러가 나네요?
3.new String[] { "_id","NAME", "ADDR" },
꼭 "_id"를 넣어야 하는건가요?
=======================================================
list.xml
====================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/Button11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="뒤로"/>
<ListView
android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>



