Vickyexpert
Vickyexpert

Reputation: 3171

Manage Radio Button Manually in Radio Group Android

I have one radio group in which there are three (3) radio buttons for images, audio and video.

Now, Currently this layout will be disable and when user will click on show options, that time this will be enable and by default it should set check on images radio button, but it is not working .

Please check below my code and help me.

 public void onClick (View v)
 {

     switch (v.getId)
     {
          case R.id.btnOptions :

                  rb_images.setEnabled(true);
                  rb_audio.setEnabled(true);
                  rb_video.setEnabled(true);

                  rb_images.setChecked(true);
                  fetchData("Images");

                  break;


          case R.id.btnFavorite :

                  rb_images.setEnabled(false);
                  rb_audio.setEnabled(false);
                  rb_video.setEnabled(false);

                  fetchData("Favorite");

                  break;
     }
 } 

Now, when I will click on favorite button it will work properly and disable all radio buttons and also set them uncheck, but when I will click on Options button, at that time all three radio button will be enabled, but image button will not set as checked. Please dont answer like define buttons and initialise radio group and all, as I have done it in onCreate method and everything it working fine without any eception, just issue is radio button not set as checked by default on option button click.

So please help me for that.

Upvotes: 1

Views: 376

Answers (1)

Vickyexpert
Vickyexpert

Reputation: 3171

Solved !

I got my answer after some R & D, as I have applied so many logic to resolve the issue, but was not able. So then I have removed Radio Group and Put Button Independently and setChecked for all buttons manually.

Upvotes: 2

Related Questions