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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -