title: Not able to get id of radiobutton via getCheckedRadioButtonId()
body: <p>I am trying to make a custom dialog box which gives radio buttons to select from n then diplay text of radio button in the textfield. This is what i tried..</p>
  
  <p>My Layout for dialog box is</p>
  
  <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="wrap_content"&gt;
  
  &lt;RadioGroup
      android:id="@+id/rg_carType"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="10dp"
      android:orientation="vertical"&gt;
  
      &lt;RadioButton
          android:id="@+id/rb_hatchD"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hatchback(Diesel)" /&gt;
  
      &lt;RadioButton
          android:id="@+id/rb_hatchP"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hatchback(Petrol)" /&gt;
  
      &lt;RadioButton
          android:id="@+id/rb_sedanD"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Sedan(Diesel)" /&gt;
  
      &lt;RadioButton
          android:id="@+id/rb_sedanP"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Sedan(Petrol)" /&gt;
  
      &lt;RadioButton
          android:id="@+id/rb_suv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="SUV" /&gt;
  &lt;/RadioGroup&gt;
  
  &lt;ImageView
      android:id="@+id/iv_carType"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="20dp"
      android:layout_toRightOf="@+id/rg_carType"
      /&gt;
  
  &lt;Button
      android:id="@+id/btn_confirmCar"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/rg_carType"
      android:layout_centerHorizontal="true"
      android:background="@drawable/button_2"
      android:text="Confirm"
      android:textColor="#fff" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the function for custom dialog box is </p>
  
  <pre><code>private void diplayCartype() {
  final Dialog dialog_car = new Dialog(FinalActivity.this);
  final RadioButton rb_select;
  RadioGroup rg_carType;
  ImageView iv_carType;
  Button btn_confirmCar;
  String sCar="?";
  dialog_car.setTitle("Select Car Type");
  
  dialog_car.setContentView(R.layout.dialog_cartype);
  
  iv_carType=(ImageView)dialog_car.findViewById(R.id.iv_carType);
  btn_confirmCar=(Button)dialog_car.findViewById(R.id.btn_confirmCar);
  rg_carType=(RadioGroup)dialog_car.findViewById(R.id.rg_carType);
  
  int selected=rg_carType.getCheckedRadioButtonId();
  rb_select=(RadioButton)dialog_car.findViewById(selected);
  
  switch(selected)
  {
      case R.id.rb_hatchD:
          iv_carType.setImageResource(R.drawable.hatch_d);
          sCar=rb_select.getText().toString();
          break;
      case R.id.rb_hatchP:
          iv_carType.setImageResource(R.drawable.hatch_p);
          sCar=rb_select.getText().toString();
          break;
      case R.id.rb_sedanD:
          iv_carType.setImageResource(R.drawable.sedan_d);
          sCar=rb_select.getText().toString();
          break;
      case R.id.rb_sedanP:
          iv_carType.setImageResource(R.drawable.sedan_p);
          sCar=rb_select.getText().toString();
          break;
      case R.id.rb_suv:
          iv_carType.setImageResource(R.drawable.suv);
          sCar=rb_select.getText().toString();
          break;
      default:
          iv_carType.setImageResource(R.drawable.suv);
          sCar="default";
  }
  final String finalSCar = sCar;
  btn_confirmCar.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          tv_carType.setText(finalSCar);
          dialog_car.dismiss();
      }
  });
  dialog_car.show();
  }
  </code></pre>
  
  <p>The problem is that the switch case executes only default condition, that means its not getting id to check. Thanks in advance.. :)</p>