2011-05-24 19 views

Respuesta

7

Esta es la manera de hacerlo:

Crear una por separado en cada RadioGroupRadioButton en el archivo de diseño XML. Por ejemplo:

<RadioGroup 
    android:id="@+id/rdoFooWrapper" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <RadioButton 
     android:id="@+id/rdoFoo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
</RadioGroup> 

<RadioGroup 
    android:id="@+id/rdoBooWrapper" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <RadioButton 
     android:id="@+id/rdoBoo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
</RadioGroup> 

Ahora, dentro del código fuente de Java, hacer algo como esto:

rdoFooWrapper = (RadioGroup) findViewById(R.id.rdoFooWrapper); 
rdoFoo = (RadioButton) findViewById(R.id.rdoFoo); 
rdoBooWrapper = (RadioGroup) findViewById(R.id.rdoBooWrapper); 
rdoBoo = (RadioButton) findViewById(R.id.rdoBoo); 

rdoFoo.setOnCheckedChangeListener(this); // implement OnCheckedChangeListener to the current class 
rdoBoo.setOnCheckedChangeListener(this); 

// ... 

@Override 
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
{ 
    rdoFooWrapper.clearCheck(); 
    rdoBooWrapper.clearCheck(); 
} 
Cuestiones relacionadas