package app.test;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
public class Test extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final RadioGroup radiogroup = (RadioGroup) findViewById(R.id.testRadioGroup);
final Button changeButton = (Button) findViewById(R.id.enableButton);
changeButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
changeOption(radiogroup);
}
});
final Button changeButton2 = (Button) findViewById(R.id.backgroundColorButton);
changeButton2.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
changeOption2(radiogroup);
}
});
}
public void changeOption(RadioGroup radiogroup) {
if (radiogroup.isEnabled()) {
radiogroup.setEnabled(false);
} else {
radiogroup.setEnabled(true);
}
}
public void changeOption2(RadioGroup radiogroup) {
radiogroup.setBackgroundColor(Color.RED);
}
}
//main.xml
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:text="Radio 1"
android:id="@+id/radio1"
/>
android:text="Radio 2"
android:id="@+id/radio2" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Set isEnabled"/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Change Background Color"/>