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));
}
有關如何實現此目的的任何建議?
你讀過**上'ListView'和適配器任何**教程? [Here's one](http://developer.android.com/resources/tutorials/views/hello-listview.html)。你可能也想看看['BaseAdapter'](http://developer.android.com/reference/android/widget/BaseAdapter.html)。編寫一個擴展它的類,如果你想顯示自定義數據。 – Felix