title: Radio Group as item in listview custom adapter
body: <p>I have made a custom adapter having different view types. I am showing two views are textview and radiogroup having variable buttons. I have written this code:</p>
  
  <p>This is my model class for different views</p>
  
  <pre><code>public class OrthoScaleModel {
  
      public static int SECONDARY_TEXTVIEW = 0;
      public static int RADIOGROUP_TEXTVIEW = 1;
  
      public int type;
      public String[] radioButtonArray;
      public String headingTitle;
      public int numberOfRadioButtons;
  
      public OrthoScaleModel(int type, String[] radioButtonArray, String headingTitle
      , int numberOfRadioButtons) {
          this.type = type;
          this.radioButtonArray = radioButtonArray;
          this.headingTitle = headingTitle;
          this.numberOfRadioButtons = numberOfRadioButtons;
      }
  }
  </code></pre>
  
  <p>And this is my custom adapter getView() method code</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      ViewHolder holder;
      int type = getItemViewType(position);
      OrthoScaleModel model = list.get(position);
  
      for (String data : model.radioButtonArray){
          Log.v("Data", data);
      }
  
      RadioButton[] buttons = new RadioButton[model.numberOfRadioButtons];
  
      if (convertView == null){
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          holder = new ViewHolder();
  
          if (type == 0){
              convertView = inflater.inflate(R.layout.secondary_heading, parent, false);
              holder.textView = (TextView) convertView.findViewById(R.id.secondaryHeadingTextView);
              convertView.setTag(holder);
          } else if (type == 1){
              convertView = inflater.inflate(R.layout.textview_radiogroup, parent, false);
              holder.radioGroup = (RadioGroup) convertView.findViewById(R.id.radio_group1);
  
              for (int i = 0; i &lt; model.numberOfRadioButtons; i++){
                  buttons[i] = new RadioButton(context);
                  holder.radioGroup.addView(buttons[i]);
                  buttons[i].setText(list.get(position).radioButtonArray[i]);
                  buttons[i].setGravity(Gravity.TOP);
                  buttons[i].setPadding(0, 5, 5, 0);
                  buttons[i].setTextSize(18);
                  convertView.setTag(holder);
              }
              convertView.setTag(holder);
          }
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      if (type == 0){
          holder.textView.setText(model.headingTitle);
      }
  
      return convertView;
  }
  
  static class ViewHolder{
      private TextView textView;
      private RadioGroup radioGroup;
  }
  </code></pre>
  
  <p>And I used it to get my listview as</p>
  
  <pre><code>  ListView listView = (ListView) findViewById(R.id.listView);
          String[] orthoScalesData = getResources().getStringArray(R.array.ortho_scales_data);
  ArrayList&lt;OrthoScaleModel&gt; list1 = new ArrayList&lt;&gt;();
          list1.add(new OrthoScaleModel(OrthoScaleModel.SECONDARY_TEXTVIEW, new String[]{}, orthoScalesData[1], 0));
  
              list1.add(new OrthoScaleModel(OrthoScaleModel.SECONDARY_TEXTVIEW, new String[]{}, orthoScalesData[2], 0));
              list1.add(new OrthoScaleModel(OrthoScaleModel.RADIOGROUP_TEXTVIEW, new String[]{orthoScalesData[3],
                      orthoScalesData[4], orthoScalesData[5], orthoScalesData[6], orthoScalesData[7], orthoScalesData[8]},
                      " ", 6));
  
              list1.add(new OrthoScaleModel(OrthoScaleModel.SECONDARY_TEXTVIEW, new String[]{}, orthoScalesData[9], 0));
              list1.add(new OrthoScaleModel(OrthoScaleModel.RADIOGROUP_TEXTVIEW, new String[]{orthoScalesData[10],
                      orthoScalesData[11], orthoScalesData[12], orthoScalesData[13], orthoScalesData[14], orthoScalesData[15]},
                      " ", 6));
  
              CustomOrthoScaleAdapter adapter = new CustomOrthoScaleAdapter(this, list1);
              listView.setAdapter(adapter);
  </code></pre>
  
  <p>But In my listview I am getting same radio button text for both radio group position.Please somebody help.</p>