我在这里从我的代码中获取对象数据,但我不知道我该怎么做。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage);
Log.d(TAG, "onCreate");
datasource = new DataSource(this);
datasource.open();
List<Encouragement> values = datasource.getAllEncouragements();
Log.d(TAG, "values");
ArrayAdapter<Encouragement> adapter = new ArrayAdapter<Encouragement>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
Log.d(TAG, "end of onCreate");
}
和
public List<Encouragement> getAllEncouragements() {
List<Encouragement> encouragements = new ArrayList<Encouragement>();
Cursor cursor = database.query(DatabaseHelper.TABLE_ENCOURAGEMENTS,
allColumns, null, null, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Encouragement encouragement = cursorToEncouragement(cursor);
encouragements.add(encouragement);
cursor.moveToNext();
}
cursor.close();
return encouragements;
}
正在列表项中生成com.example.myActivity.myObject@34563475。