I am building a custom adapter for a listview - I would like this adapter to give the listview alternating background colours.
boolean alternate = false;
@
You can do in your adapter
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
inflater = ((Activity) context).getLayoutInflater();
convertView = inflater.inflate(resourceId, parent, false);
}
Person user = getItem(position);
if(user.isCharged)
convertView.setBackgroundColor(Color.BLUE);
}
that will be applied in all your items