我在使用 ListView 显示 sqlite 数据库中的数据项时遇到问题。当我尝试单击按钮后查看数据时,它显示:
com.LocationReminder 和 Task@4053afb0
有点奇怪。
这是我的 readReminder.java
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class readReminder extends ListActivity {
private DBReminder operasiDB;
private ArrayList<Task> daftarTugas;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.read_task);
operasiDB = new DBReminder(this);
daftarTugas = operasiDB.viewAllTask();
ArrayAdapter<Task> adapter = new ArrayAdapter<Task>(this,
android.R.layout.simple_list_item_1, daftarTugas);
setListAdapter(adapter);
}
}
这是我显示数据库中所有数据的代码
public ArrayList<Task> viewAllTask() {
openConn();
ArrayList<Task> tugas = new ArrayList<Task>();
Cursor curs = db.rawQuery("select * from " + TableName, null);
if (curs.moveToFirst()) {
do {
Task task = new Task();
task.setId(Integer.parseInt(curs.getString(curs.getColumnIndex(ID))));
task.setLatitude(Integer.parseInt(curs.getString(curs.getColumnIndex(LATITUDE))));
task.setLongitude(Integer.parseInt(curs.getString(curs.getColumnIndex(LONGITUDE)));
task.setRadius(Integer.parseInt(curs.getString(curs.getColumnIndex(RADIUS))));
task.setAlamat(curs.getString(curs.getColumnIndex(ALAMAT)));
task.setKonteks(curs.getString(curs.getColumnIndex(KONTEKS_TUGAS)));
tugas.add(task);
} while (curs.moveToNext());
}
closeConn();
return tugas;
}
在 SQLite Manager Eclipse 中,数据也与表一起出现。请帮我。谢谢...