Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change the image of a button
    primarykey
    data
    text
    <p>My problem here is how to display a new image for button after it was clicked but the condition is from the other class. Im a newbie here and I want to know how to connect the class from other class. I tried the Intent ...</p> <p>Here is my code</p> <p>This is the class of our Question...</p> <pre><code>@Override // TODO Auto-generated method stub public void onClick(View v) { String answer = "Marianas Trench"; String answer2 = "marianas trench"; String answer3 = "MARIANAS TRENCH"; String check = input.getText().toString(); if (check.contentEquals(answer)){ tvresult.setText("Correct"); Intent myIntent= new Intent("com.turtleexploration.LEVEL1"); startActivity(myIntent); }else if (check.contentEquals(answer2)){ tvresult.setText("Correct"); Intent myIntent= new Intent("com.turtleexploration.LEVEL1"); startActivity(myIntent); }else if (check.contentEquals(answer3)){ tvresult.setText("Correct"); Intent myIntent = new Intent("com.turtleexploration.LEVEL1"); startActivity(myIntent); }else{ tvresult.setText("Wrong"); } Intent intObj = new Intent(Question.this, Level1.class); intObj.putExtra("ANSWER", answer); startActivity(intObj); } </code></pre> <p>And this is the Question Selection class..</p> <pre><code>ImageButton l1 = (ImageButton) findViewById(R.id.l1); TextView t1 = (TextView) findViewById(R.id.t1); Intent intename = getIntent(); String mainans = "Marianas Trench"; String ans = (String) intename.getSerializableExtra("ANSWER"); if (ans == mainans){ l1.getBackground().equals(getResources().getDrawable(R.drawable.m1)); t1.setText("Correct"); }else{ } </code></pre> <p>The button is in the Question Selection menu...</p>
    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.
 

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