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?

enter image description here

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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -