1package com.xtremelabs.robolectric.shadows; 2 3import android.view.ViewParent; 4import android.widget.RadioButton; 5import android.widget.RadioGroup; 6import com.xtremelabs.robolectric.internal.Implementation; 7import com.xtremelabs.robolectric.internal.Implements; 8 9/** 10 * Shadows the {@code android.widget.RadioButton} class. 11 */ 12@SuppressWarnings({"UnusedDeclaration"}) 13@Implements(RadioButton.class) 14public class ShadowRadioButton extends ShadowCompoundButton { 15 16 @Implementation 17 @Override public void setChecked(boolean checked) { 18 super.setChecked(checked); 19 ViewParent viewParent = getParent(); 20 21 /* This simulates the listener a parent RadioGroup would have, listening to the 22 checked state it's child RadioButtons. Feel free to implement properly. 23 */ 24 if (viewParent instanceof RadioGroup) { 25 ((RadioGroup) viewParent).check(getId()); 26 } 27 } 28} 29