Question: I am using a YouTube tutorial series to create an Android app. When using this code:

```
someRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

```

I get an error with 'setOnCheckedListener'.

The error is this:

> 
> The method
>  setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener) in the
>  type RadioGroup is not applicable for the arguments (new
>  CompoundButton.OnCheckedChangeListener(){})
> 
> 
> 

I have read that I should import `android.widget.RadioGroup.OnCheckedChangeListener;`, instead of the listener for the CompoundButton, but I use the CompoundButton.

What can I do to fix this error?

Answer: 
It seems your package imports conflict with each other.

try using this way

```
someRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() 

```
Hope this helps you out. Here is basic example of how to use `RadioGroup` and `setOnCheckedChangeListener`.

|Java
-----

```
 private void setupRadios() {
    RadioButton radioMale =(RadioButton) findViewById(R.id.radioMale);
    RadioButton radioFemail = (RadioButton) findViewById(R.id.radioFemale);
    RadioButton radioOther = (RadioButton) findViewById(R.id.radioOther);
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radio_group);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            int buttonId = radioGroup.getCheckedRadioButtonId();
            switch(buttonId) {
                case R.id.radioMale:
                    Toast.makeText(getApplicationContext(), "Your Male", Toast.LENGTH_SHORT).show();
                    break;
                case R.id.radioFemale:
                    Toast.makeText(getApplicationContext(), "Your Female", Toast.LENGTH_SHORT).show();
                    break;
                case R.id.radioOther:
                    Toast.makeText(getApplicationContext(), "Your Other", Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    });
}

```

|XML
----

```
<RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/input_validation"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:id="@+id/radio_group">
    <RadioButton
        android:id="@+id/radioMale"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Male" />
    <RadioButton
        android:id="@+id/radioFemale"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Female" />
    <RadioButton
        android:id="@+id/radioOther"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Other" />
</RadioGroup>

```

|Output
-------

By default none of the radio buttons will be checked, Once clicked the radio button will be checked.
![enter image description here](https://i.stack.imgur.com/j3llA.png)