I have created an ArrayList<HashMap<String, String>>
collection to hold my data for ListView
. I'm using SimpleAdapter
.
Is it possible to change background of list item when list item's ID % 10 == 0?
Here is the code (method generating layout):
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);
}