SimpleCursorAdapter - 绑定到ListView中的多个项值

时间:2010-01-12 22:32:20

标签: android listview

我有以下代码来实例化一个SimpleCursorAdapter以与ListView一起使用。正如您所看到的,我已经通过了R.layout.log_item来显示列表项,以及一个要绑定到(TripDate)的值/控件。

SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.log_item,c,new String[] {DBAdapter.KEY_LOG_TRIPDATE},new int[]{R.id.txtTripDate});

这是有效的

我目前在布局xml中只有一个小部件,一个用于保存TripDate的TextView。 如何为布局中的其他窗口小部件传递多个绑定参数?所以我也可以显示其他信息。

感谢 帕特里克

1 个答案:

答案 0 :(得分:3)

SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.log_item,c,new String[] {DBAdapter.KEY_LOG_TRIPDATE, DBAdapter.KEY_FOO, DBAdapter.KEY_BAR},new int[]{R.id.txtTripDate, R.id.otherid1, R.id.otherid2});