我创建了一个ArrayList<HashMap<String, String>>
集合来保存我的数据ListView
。我正在使用SimpleAdapter
.
当列表项的 ID % 10 == 0 时,是否可以更改列表项的背景?
这是代码(方法生成布局):
private void fillData() {
Cursor c = this.mDbManager.getNgOrderDetailByOrderNumber(this.mNumber);
ArrayList<HashMap<String, String>> items = new ArrayList<HashMap<String, String>>();
if (!c.isAfterLast()) {
do {
// ... filling HashMap and putting it to ArrayList
} while (c.moveToNext());
}
SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.list_item,
new String[] { "product", "ordered", "price", "discount" },
new int[] { R.id.ProductTextView, R.id.OrderedTextView,
R.id.PriceTextView, R.id.DiscountTextView });
ListView l = (ListView) findViewById(android.R.id.list);
l.setAdapter(adapter);
}