How To Change The Image Of A Button
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 clas
Solution 1:
it seems that you did not use the Bundle which carries the data. Intent only calls for the next activity. Bundle must be included.
like:
Bundleb=newBundle();
b.putString("ANSWER", answer);
IntentintObj=newIntent(Question.this, Level1.class);
b.putExtras(b);
startActivity(intObj);
and in the next class. use this to get the data passed:
Bundleb=newBundle();
b = getIntent().getExtras();
StringGotanswer= b.getString("ANSWER");
and use the string Gotanswer
to use it.
BUT one more thing, if you wanna pass the string ANSWER to the next class, it would be impossible in this code because inside your every condition, there is a line that starts the next class such as:
IntentmyIntent=newIntent("com.turtleexploration.LEVEL1");
startActivity(myIntent);
doing this will start the next class without passing through the intObj
code below.
this is if I'm not mistaken. :)
plus, instead of using If-Else-If
, switch
is much better for this kind.
Explain your issue further when you see this answer.
Kaya yan pre! haha
Post a Comment for "How To Change The Image Of A Button"