android - SimpleAdapter not keeping position when scrolling -
i have simpleadapter i'm using display 2 line listview. want 15th position on simple adapter of different format when scroll listview around, looses position , formatting changes positions. there solution this? i've tried mucking around convertview can't seem right format. code below. thanks!
simpleadapter adapter = new simpleadapter(this, data, android.r.layout.simple_list_item_2, new string[] {"title", "publisher"}, new int[] {android.r.id.text1, android.r.id.text2}){ public view getview(int position, view convertview, viewgroup parent) { view view = super.getview(position, convertview, parent); if (position == 15) { textview text1 = (textview) view.findviewbyid(android.r.id.text1); text1.settextcolor(color.white); textview text2 = (textview) view.findviewbyid(android.r.id.text2); text2.settextcolor(color.white); view.setbackgroundcolor(getresources().getcolor(r.color.teal_dark)); } return view; } };
try add else clause reset format default format
if (position == 15) { textview text1 = (textview) view.findviewbyid(android.r.id.text1); text1.settextcolor(color.white); textview text2 = (textview) view.findviewbyid(android.r.id.text2); text2.settextcolor(color.white); view.setbackgroundcolor(getresources().getcolor(r.color.teal_dark)); } else { textview text1 = (textview) view.findviewbyid(android.r.id.text1); text1.settextcolor(color.black); textview text2 = (textview) view.findviewbyid(android.r.id.text2); text2.settextcolor(color.black); view.setbackgroundcolor(getresources().getcolor(r.color.teal_light)); }
Comments
Post a Comment