我正在尝试从 SQLite-db 读取,将结果放入自定义类型容器的对象中,将容器的内容放入 ArrayList 中,我可以构建一个由 arraylist 填充的列表视图。我被困在尝试将填充的容器对象传递给 ArrayList 的点:
ArrayList<Container> myListContent = new ArrayList<Container>();
{
Container conSelected = db.readContainer(i);
int s1 = conSelected.getId();
Log.i("LISTE", "id = " + s1);
String s2 = conSelected.getVorname();
Log.i("LISTE", "vorname = " + s2);
String s3 = conSelected.getName();
Log.i("LISTE", "name = " + s3);
// Container to the ArrayList
//THIS NEXT COMMAND IS TROUBLING ME. ALL THREE GIVE THE SAME LOG
//myListContent.add(conSelected);
//myListContent.add(new Container(conSelected.getId(), conSelected.getVorname(), conSelected.getName()));
//myListContent.add(new Container(conSelected));
Log.i("LISTE", "line = " + myListContent);
}
//this.myAdapter = new ListActivity(this, R.layout.row, myListContent);
我的 Logcat 说:
03-11 18:17:43.336: I/LISTE(7477): id = 1
03-11 18:17:43.336: I/LISTE(7477): vorname = Fred
03-11 18:17:43.336: I/LISTE(7477): name = Einsner
03-11 18:17:43.336: I/LISTE(7477): line = [null]
...
03-11 18:17:43.375: I/LISTE(7477): id = 6
03-11 18:17:43.375: I/LISTE(7477): vorname = Wolf
03-11 18:17:43.375: I/LISTE(7477): name = Sechsland
03-11 18:17:43.375: I/LISTE(7477): line = [null, null, null, null, null, null]
谁能帮我这个?我还是个菜鸟:(