title: How to generate dynamic RadioButton with a radiongroup in adapterView?
body: <p>I have a Dynamic list, and I want to show that list in adapter view with radio buttons. in one group.</p>
  <p>I used:</p>
  <pre><code>public class Type2Adapter extends BaseAdapter{
      Context context;    
      LayoutInflater inflater;
      ArrayList&lt;QueOption&gt; oplist;
      String list1;
      int count;
      RadioGroup radiogroup;
      String dot,more;
      public Type2Adapter(Context context,ArrayList&lt;QueOption&gt; arrayList){
          this.context = context;
          inflater = LayoutInflater.from(context);
          oplist = arrayList;
          count = oplist.size();
          if(count&gt;=1){
              count = oplist.size();
          }else{
              count = 1;
          }
      }
  
  
      @Override
      public int getCount() {     
          return count;       
      }
  
      @Override
      public Object getItem(int position) {
          return position;
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          
          ViewHolder holder;      
          if(convertView == null){    
              
              holder = new ViewHolder();  
              convertView = inflater.inflate(R.layout.type2_option, null);            
  //          holder.nameList = (RadioButton)convertView.findViewById(R.id.optionRadio);          
              holder.layout = (LinearLayout)convertView.findViewById(R.id.type2);     
              radiogroup = (RadioGroup)convertView.findViewById(R.id.optionRadioGroup);
              convertView.setTag(holder);
          }
          else{
              holder = (ViewHolder) convertView.getTag();
          }           
              holder.layout.setBackgroundResource(R.drawable.list_back_rowcolor);
  //          holder.nameList.setText(oplist.get(position).getOptionName());
              RadioButton newRadioButton = new RadioButton(context);
              newRadioButton.setId(position); 
              newRadioButton.setText(oplist.get(position).getOptionName());           
              radiogroup.addView(newRadioButton); 
              
          return convertView;
      }
      
      public class ViewHolder{
          
          private LinearLayout layout;
          private RadioButton nameList;
      }
      
  }
   
  </code></pre>
  <p>XMl:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&gt;
    
    &lt;LinearLayout
      android:id=&quot;@+id/type2&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;horizontal&quot; &gt;
    
          &lt;RadioGroup 
              android:id=&quot;@+id/optionRadioGroup&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot; &gt;  
              
              
          &lt;/RadioGroup&gt;   
            
    &lt;/LinearLayout&gt;  
    
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>what should i do to solve my problem.</p>