title: Preparing customized radio group type of layout
body: <p>I am trying to prepare custom <strong>radiogroup</strong> like layout in the below image. I have nearly 8-10 rows to do that. So, I prepared one <code>linear layout</code> which has horizontal orientation and added the <code>imageview</code>, <code>textview</code> and <code>radiobutton</code> programatically.</p>
  
  <p><img src="https://i.stack.imgur.com/kQ4hx.png" alt="enter image description here"></p>
  
  <p>So if I check on one <code>radio button</code>, the other radio buttons should automatically unchecked. Before going to that task itself, I got another problem that if my radio buttons are checked once, then the radio button are not uncheckable though clicked on them. Below is my code.</p>
  
  <pre><code>public class MainActivity extends Activity{
  
  RadioButton[] radioBtns = new RadioButton[10];
  
      String texts[] = {"text1", "text2", .... "text10"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
  
          entireLayout = (LinearLayout)findViewById(R.id.main_layout);
  
  
          for(int i =0; i&lt;10; i++)
          {
              LinearLayout rowLayout=new LinearLayout(this);
              radioBtns[i] = new RadioButton(this);
  
              radioBtns[i].setId(i);
              radioBtns[i].setOnCheckedChangeListener(cblistener);
              ImageView imageView = new ImageView(this);
  
  
              TextView tv = new TextView(this);
              tv.setText(texts[i]);
  
              rowLayout.addView(imageView);
              rowLayout.addView(tv);
                          rowLayout.addView(radioBtns[i]);
  
              entireLayout.addView(rowLayout);
  
                  View line = new View(this); 
                  line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor));
                  entireLayout.addView(line, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 1));
  
  
          }
           }
  
  CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener()
      {
        public void onCheckedChanged(CompoundButton checkedbutton, boolean paramAnonymousBoolean)
        {
  
          switch (checkedbutton.getId())
          {
  
          case 0:
            Log.d("tag", "checked 0th position");
  
            break;
            ..........................
            ..........................
          }
        }
       };
  }
  </code></pre>
  
  <p>I have observed through keeping logs. The control enters <strong>onCheckedChanged()</strong> for the first time when those are getting checked, but not when unchecked. I wonder how those are uncheckable.</p>
  
  <p><strong>OR</strong>  According to my requirement I have one more idea to prepare this layout like I prepare one more layout for the <strong>row in xml</strong>. Then inflating the view 10 times. But then also, how can I check only one radio button so that other selected one gets unchecked. Can someone please suggest me how to achieve this kind of <strong>radiogroup</strong> through the best way?</p>
  
  <p><strong>Note:</strong> I have kept my above code because to show what I have tried. If it is completely wrong way, please go easy and please suggest me how to get that done.</p>