android - Change ImageView background when radioButton is clicked inside RadioGroup -
android - Change ImageView background when radioButton is clicked inside RadioGroup -
in application have 2 radio buttons place within radio grouping , have single image view. 2 radio buttons choices name sun , moon , image view set sun image.
i want alter set image moon when clicked radio button name moon. how can within radio group?
radiogroup radiogroup = (radiogroup) findviewbyid(r.id.[add id here <---without [].]); int checkedradiobutton = radiogroup.getcheckedradiobuttonid(); switch (checkedradiobutton) { case r.id.radiobutton1 : imageview.setbackgroundimage(r.drawable.sun); break; case r.id.radiobutton2 : image view.setbackgroundimage(r.drawable.moon); break; }
note - functionality, without xml. suppose smart plenty manage hook xml.
note2 - might mistaking this: setbackgroundimage. might bit different.
android android-imageview android-radiogroup
Comments
Post a Comment