SimpleCursorAdapter - 在ListView中绑定多个项值

3

我有以下代码来实例化一个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中只有一个小部件,一个TextView来保存TripDate的信息。如何为布局中的其他小部件传递多个绑定参数?这样我就可以显示其他信息了。

谢谢 帕特里克

1个回答

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});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接