i have adapter present list of items. need change text color of items on firstposition , secondposition. data list doesn't change, can't use notifydatasetchanged. how can this?
this method getview in adapter
public view getview(int position, view convertview, viewgroup parent) { viewholder holder; if (convertview == null){ convertview = layoutinflater.from(context).inflate(r.layout.alphabet_item, parent, false); holder = new viewholder(); holder.lettertextview = (textview) convertview.findviewbyid(r.id.letter_text); convertview.settag(holder); } holder = (viewholder) convertview.gettag(); holder.lettertextview.settext(string.valueof(alphabetlist.get(position))); if (firstposition == position) { holder.lettertextview.settextcolor(context.getresources().getcolor(r.color.coloraccent)); } else if (secondposition == position){ holder.lettertextview.settextcolor(context.getresources().getcolor(r.color.colorprimary)); } else { holder.lettertextview.settextcolor(context.getresources().getcolor(r.color.colortext)); } return convertview; }
the firstposition , secondposition declare integer
i didnot question exactly. think need @ "firstposition" && "secondposition" want set color.
for need check both position in same if condition
if(position == firstposition || position == secondposition){ holder.txtview.settextcolor(colorid); }
Comments
Post a Comment