Changing image on click Android Listview -


i've got problem code. when click on item in list, it's supposed change image displayed next text. however, nothing changes when click.

what doing wrong?

public class changeimage extends listactivity {  boolean state1 = true; boolean state2 = false; boolean state3 = false;  public void oncreate(bundle icicle) {     super.oncreate(icicle);     string[] values = new string[] {             "listitem1",              "listitem2",              "listitem3"};     arrayadapter<string> adapter = new arrayadapter<string>(this,             r.layout.change_image, r.id.label, values);     setlistadapter(adapter); }  @override public void onlistitemclick(listview l, view v, int position, long id){     if(state1){        imageview arrowview=(imageview) findviewbyid(r.id.labelimage);        arrowview.setimageresource(r.drawable.icon1);}    else if(state2){        imageview arrowview=(imageview) findviewbyid(r.id.labelimage);        arrowview.setimageresource(r.drawable.icon2);}    else if(state3){        imageview arrowview=(imageview) findviewbyid(r.id.labelimage);        arrowview.setimageresource(r.drawable.icon3);}    } }     

thank answers ^^

set , reset boolean flag properly,and change picture used touching actions...

if(state1) { state3=false;state1=false;state2=true; }


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -