我正在使用数据库,从中获取光标,然后使用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);
Run Code Online (Sandbox Code Playgroud)
simplecursoradapter对构造函数中传递给它的信息做了什么?格式错误的参数之一是什么?这是我用来查看是否有效的每一行的简单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>
Run Code Online (Sandbox Code Playgroud)
这是我加载游标的方法:
listCursor = myDataBase.query(ITEMS_TABLE, null, "location" +" = ?", new String[]{IN_SPECIAL_LIST}, null, null, "item");
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚问题是什么.我通过一些调试来运行它,当II创建新的simplecursoradapter时会出现问题.