title: Radio group not working in android
body: <p>I ahve made a simple radioButton demo in android.In that i have put a radiogroup with two radio buttons named "male" and "female"...and a button .I want is when one of them pressed the name related to that particular radiobutton should be in toast.I have tried as below thats not working:</p>
  
  <p><strong>Activity.java</strong></p>
  
  <pre><code>package com.example.radiobuttondemo;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.RadioButton;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
  RadioButton rd1,rd2;
  Button b;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      rd1=(RadioButton)findViewById(R.id.radio0);
      rd2=(RadioButton)findViewById(R.id.radio1);
      b.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
  
              if(rd1.isChecked()){
                  Toast.makeText(getApplicationContext(), "male", 0).show();
              }
              else{
                  Toast.makeText(getApplicationContext(), "Female", 0).show();
              }
  
  
          }
      });
      }
  
  
  
  }
  </code></pre>