Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting window background with radio buttons
    primarykey
    data
    text
    <p>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. </p> <p>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?</p> <p>here is my code for the radio buttons</p> <pre><code>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); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload