java - Set ImageView based on user selection in settings android -


i attemping make app change image based on users selection of listpreference in settings of application. there 2 pictures, forest,and ocean. when ocean selected value sent string 1, , 2 forest, when run code throws error saying "source not found." siggestions?

 public void showusersettings() {      string name;      string pic;      sharedpreferences sharedprefs = preferencemanager.getdefaultsharedpreferences(this);      name = sharedprefs.getstring("your_name", "null");      pic = sharedprefs.getstring("pic_what", "for");      int whatpic = integer.parseint(pic);      textview tvname = (textview) findviewbyid(r.id.tvname);      tvname.settext(name);      if(whatpic==1) {               imageview img = (imageview) findviewbyid(r.id.iview);              img.setimageresource(r.drawable.ocean);      }else if(whatpic==2); {          imageview img = (imageview) findviewbyid(r.id.iview);          img.setimageresource(r.drawable.forest);          }   } 

}


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -