title: Add RadioButton inside RadioGroup in ListView
body: <p>I've been trying to add radio buttons inside a radio group in a listview. 
  So, if I click a radio button it checks it but if I click another one, it doesn't remove the previous selection. I'm a beginner in android so forgive me If I'm doing something terribly wrong.</p>
  
  <h2>This is my Main Activity and I have the radio group outside the list</h2>
  
  <pre><code>&lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:paddingTop="20dp"&gt;
  
              &lt;RadioGroup
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/car_list_radio_group"&gt;
  
                  &lt;ListView
                      android:id="@+id/vehicle_list"
                      android:clickable="true"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"&gt;&lt;/ListView&gt;
  
              &lt;/RadioGroup&gt;
  
          &lt;/LinearLayout&gt;
  </code></pre>
  
  <h2>This is my custom view for each item on the list</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:alwaysDrawnWithCache="true"
      android:backgroundTint="#ffffff"&gt;
  
  
      &lt;RadioButton
          android:id="@+id/car_selected"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_centerVertical="true"
          android:buttonTint="@color/tesla_red"
          android:padding="10dp"
          android:text=""
          android:textColor="@android:color/white"
          android:textSize="16sp"
          android:textStyle="bold" /&gt;
  
      &lt;TextView
          android:id="@+id/vin"
          android:layout_width="183dp"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_below="@+id/car_selected"
          android:layout_marginStart="30dp"
          android:paddingLeft="10dp"
          android:paddingRight="10dp"
          android:textColor="@android:color/white"
          android:textSize="12sp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <h2>This is my adapter for the list</h2>
  
  <pre><code>private final class VehiclesAdapter extends BaseAdapter {
  
          LayoutInflater inflter;
          ArrayList&lt;VehicleItem&gt; vehiclesArray;
  
          public VehiclesAdapter(Context applicationContext, ArrayList&lt;VehicleItem&gt; items) {
              vehiclesArray = items;
              inflter = (LayoutInflater.from(applicationContext));
          }
  
          @Override
          public int getCount() {
              return vehiclesArray.size();
          }
  
          @Override
          public Object getItem(int position) {
              return null;
          }
  
          @Override
          public long getItemId(int position) {
              return Long.parseLong(vehiclesArray.get(position).getId());
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
  
              VehicleHolder holder;
              VehicleItem vehicleItem = vehiclesArray.get(position);
  
              if (convertView == null) { // if convertView is null
                  convertView = inflter.inflate(R.layout.vehicle_item, parent, false);
  
                  holder = new VehicleHolder();
                  holder.name = convertView.findViewById(R.id.car_selected);
                  holder.vin = convertView.findViewById(R.id.vin);
  
                  // initialize views
                  convertView.setTag(holder);  // set tag on view
              } else {
                  holder = (VehicleHolder) convertView.getTag();
                  // if not null get tag
                  // no need to initialize
              }
  
              if(vehicleItem.getId().equals(currentVehicle)){
                  holder.name.setChecked(true);
              }
  
              holder.name.setText(vehicleItem.getName());
              holder.vin.setText(vehicleItem.getVin());
  
              //update views here
              return convertView;
          }
      }
  </code></pre>
  
  <p>If you need to see something else please let me know.</p>