listview - How to give a two different color to the list items of a customized list-view in android? -
can tell me how give 2 different color list items of customized list-view in android? below image.is possible?
suggestion please
thanks precious time!..
this code you,
insert code in custom list adapter,
public class listadapter extends baseadapter{ context ctx; layoutinflater linflater; list<string> data; listadapter(context context, list<string> data) { ctx = context; this.data = data; linflater = (layoutinflater) ctx .getsystemservice(context.layout_inflater_service); } @override public int getcount() { return data.size(); } @override public object getitem(int position) { return data.get(position); } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { view view = convertview; if (view == null) { view = linflater.inflate(r.layout.listitem, parent, false); } // logic added here if (position % 2 == 0) { view.setbackgroundresource(r.drawable.artists_list_backgroundcolor); } else { view.setbackgroundresource(r.drawable.artists_list_background_alternate); } ((textview) view.findviewbyid(r.id.yourtext)).settext(data.get(position)); return view; } }
Comments
Post a Comment