i have an application i am working on that has a radioButton group that changes the image background of my main activity. it is working well with one issue i cant seem to solve.
the background always defaults back to the holo background after i switch screens or resart the app. the radio buttons are set up to press properly with a selector xml in drawables and the images switch flawlessly but just don't stick. also how would i spread this across all classes without recreating the radio buttons on every screen?
here is my code for the radio buttons
public class MainActivity extends Activity {
private final String TAG = "Main Activity";
Button rButton2;
Button rButton1;
Button rButton;
Button mButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RelativeLayout ll=(RelativeLayout) findViewById(R.id.RelativeLayout);
rButton2 = (Button) findViewById(R.id.radio2);
rButton1 = (Button) findViewById(R.id.radio0);
rButton = (Button) findViewById(R.id.radio1);
rButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.i(TAG, "onStart");
ll.setBackgroundResource(R.drawable.background1);
}
});
rButton1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.i(TAG, "onStart");
ll.setBackgroundResource(R.drawable.background);
}
});
rButton2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.i(TAG, "onStart");
ll.setBackgroundResource(R.drawable.background2);
}
});
}