Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do update an activity properties from an intent?
    primarykey
    data
    text
    <p>Currently have a situation where I am trying to use a button that loads a dialog. When the dialog opens it allows you to choose a colour and then that colour selected is used to define the button you originally clicked. However am really stuck. </p> <p>Main class</p> <pre><code>package dom.MasterMind.Com; public class NewGameActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.newgame); Button choiceOne = (Button) findViewById(R.id.choiceOne); Button choiceTwo = (Button) findViewById(R.id.choiceTwo); Button choiceThree = (Button) findViewById(R.id.choiceThree); Button choiceFour = (Button) findViewById(R.id.choiceFour); final ColorPicker dialog = new ColorPicker(this); choiceOne.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.show(); } }); choiceTwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.show(); } }); choiceThree.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.show(); } }); choiceFour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.show(); } }); } } </code></pre> <p>Dialog class</p> <pre><code>package dom.MasterMind.Com; public class ColorPicker extends Dialog{ public ColorPicker(Context context) { super(context); setContentView(R.layout.colorpicker); Button btnBlack = (Button)findViewById(R.id.btnBlack); Button btnBlue = (Button)findViewById(R.id.btnBlue); Button btnGreen = (Button)findViewById(R.id.btnGreen); Button btnPurple = (Button)findViewById(R.id.btnPurple); Button btnRed = (Button)findViewById(R.id.btnRed); Button btnYellow = (Button)findViewById(R.id.btnYellow); final Button test = (Button)findViewById(R.id.choiceOne); btnBlack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); test.setBackgroundColor(R.id.btnBlack); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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