2

我正在尝试读取 SQLite 表中的所有行并在ListView. 这就是我逐行阅读它们的方式:

//---get all titles---
db.open();
Cursor c = db.getAllTitles();
String text = "";
if (c.moveToFirst()){
    do {          
        DisplayTitle(c, text);
    } while (c.moveToNext());
}
db.close();

public void DisplayTitle(Cursor c, String text){
      ListView.setText("id: " + c.getString(0) + "\n" + "ISBN: " + c.getString(1) 
    + "\n" + "TITLE: " + c.getString(2) + "\n" + "PUBLISHER:  " + c.getString(3));
} 

关于如何实现这一目标的任何建议?

4

1 回答 1

2

您必须使用自定义 CursorAdapter。看看这个教程:

http://thinkandroid.wordpress.com/2010/01/11/custom-cursoradapters/

于 2011-06-20T13:16:56.383 回答