我的数据库是绝对正确填入(< 3 SQLite数据库浏览器),但是当我尝试列出在一个视图中的所有记录,我得到如下:的Android SQLite的返回游标垃圾
[email protected]
[email protected]
[email protected]
我使用simple_list_item_1和一个ArrayAdapter。以上活动课
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_saved_objects);
datasource = new ObjectsDatabase(this);
datasource.open();
List<Object> values = datasource.getSavedObjects();
ArrayAdapter<ObjectName> adapter = new ArrayAdapter<ObjectName>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
}
XML布局:
在我的活动类创建声明
<LinearLayout
android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButton1Click"
android:text="@string/menu_back" />
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
有什么想法?
你为什么使用ArrayAdapter而不是SimpleCursorAdapter(即设计有光标和SQLite工作)? – Everett