Android, simply view question about view reset
Posted
by
javano
on Stack Overflow
See other posts from Stack Overflow
or by javano
Published on 2011-01-06T01:13:15Z
Indexed on
2011/01/06
1:53 UTC
Read the original article
Hit count: 522
I have a button in my activity, when you click the button an if statement is ran against its text label;
if(BTN_1.getText()=="firsttext"){
//do some stuff, then...
BTN_1.setText("secondtext");
}else if(BTN_1.getText()=="secondtext"){
//do other stuff, then...
BTN_1.setText("firsttext");
}
Firstly, if I hit the home button and go back to the desktop and then click back onto my app the view has reset its self; if I press the button and leave it in a state where the text of the button is "secondtext", when I return to my app it says "firsttext", how can I stop the view of my app refreshing its self like this?
Secondly, under my XML layout I have defined the buttons text; android:text="firsttext" But this won't actually match my if statement above, under onCreate of this app I have: BTN_CONNECT.setText("Connect"); But visually the text of the button is exactly the same, why won't it match?
Thanks for reading :)
© Stack Overflow or respective owner