私はデータベースを使用していて、データベースからカーソルを取得してから、simplecursoradapterを使用してリストビューにデータを入力しています。新しいsimplecursoradapterを作成するとアプリがクラッシュする理由がわからないようです。私のカーソルはシングルトンオブジェクトに含まれています。このクラスのデータ変数を介してそれを参照しています。
String[] columns = new String[] {"item", "quantity", "days"};
int[] to = new int[] { R.id.nametext, R.id.quantitytext, R.id.dayslefttext};
SimpleCursorAdapter sCA = new SimpleCursorAdapter(this, R.layout.itemrow, data.listCursor, columns, to);
listView1.setAdapter(sCA);
simplecursoradapterは、コンストラクターで渡された情報をどのように処理しますか?パラメータの1つが間違った形式ですか?これが機能するかどうかを確認するために使用している各行の単純なxmlファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Loading Screen"
android:id="@+id/nametext"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Loading Screen"
android:id="@+id/quantitytext"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Loading Screen"
android:id="@+id/dayslefttext"/>
</LinearLayout>
カーソルをロードする方法は次のとおりです。
listCursor = myDataBase.query(ITEMS_TABLE, null, "location" +" = ?", new String[]{IN_SPECIAL_LIST}, null, null, "item");
問題が何なのかわかりません。これをいくつかのデバッグで実行しましたが、IIが新しいsimplecursoradapterを作成すると問題が発生します。