如下面的代碼所示,是否可以在列表視圖中顯示來自sqlite數據庫的以下數據而不是以下內容?在列表視圖中顯示來自sqlite數據庫的數據而不是吐司?
btnlist = (Button) findViewById(R.id.btnlist);
btnlist.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
handler = new Datahandler(getBaseContext());
String getName, getaddress, getDate, getTime, getSchoolName;
getName = "";
getaddress = "";
getDate = "";
getTime = "";
getSchoolName = "";
handler.open();
Cursor C = handler.returnData();// return actual data from
// database
if (C.moveToFirst()) {
do {
getName = C.getString(0);
getaddress = C.getString(1);
getDate = C.getString(2);
getTime = C.getString(3);
getSchoolName = C.getString(4);
} while (C.moveToNext());
}
handler.close();
Toast.makeText(
getBaseContext(),
" Name :" + getName + "Address :"
+ getaddress + "Date :" + getDate + "Time :"
+ getTime + "School :" + getSchoolNname,
Toast.LENGTH_LONG).show();
}
});
}
只需使用'SimpleCursorAdapter'。 – 2014-10-27 16:54:41
你知道該怎麼做嗎?我錯了 – user3417481 2014-10-27 17:14:08