मैंने ListView
के लिए अपना डेटा रखने के लिए ArrayList<HashMap<String, String>>
संग्रह बनाया है। मैं SimpleAdapter
का उपयोग कर रहा हूं।रंगीन वस्तुओं की पृष्ठभूमि के साथ कस्टम ListView कैसे करें?
सूची आइटम की आईडी% 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);
}
नीचे बहुत बहुत शुक्रिया का उपयोग किया है हल –