我想记录一个数组列表的内容。 arraylist包含一个具有4个参数的自定义对象。当我执行下面的代码时,我得到以下日志。我想是的[姓名,班级,三十九十],[姓名,班级,三十九十]等问题logging arraylist
自定义对象类的字符串:
public class Data {
String NAME;
String CLASS;
String THIRTY;//this is the thirty day supply
String NINETY;//this is the ninety day supply
public Data(){
super();
}
public Data(String NAME, String CLASS, String THIRTY, String NINETY){
super();
this.NAME = NAME;
this.CLASS = CLASS;
this.THIRTY = THIRTY;
this.NINETY = NINETY;
}
}
活动:
ArrayList<Data> array = new ArrayList<Data>();
Cursor c = mDBHelper.getReadableDatabase().query(Constants.K_Table, null, Constants.Name +"=?", new String[] {SEARCH}, null, null, null);
startManagingCursor(c);
if (c.moveToFirst()){
NAME = c.getString(c.getColumnIndex(Constants.Name));
CLASS = c.getString(c.getColumnIndex(Constants.Class));
THIRTY = c.getString(c.getColumnIndex(Constants.Month));
NINETY = c.getString(c.getColumnIndex(Constants.Three_Month));
array.add(new DrugData(NAME, CLASS, THIRTY, NINETY));
Log.d(TAG, "array contains: "+ array.toArray().toString());
}while(c.moveToNext());
日志:
01-28 22:31:44.742: D/Activity(23656): the array contains: [[email protected]]
感谢状,伟大工程!优秀的解释 – benbeel 2012-01-29 16:04:01