0

The first Activity has two Radio Buttons and the user selects either one, and presses 'Next', which shows the second Activity. The second Activity has a 'Back' button, when I click that I go to the first Activity, but the Radio Buttons aren't selected. How can I make it so that the Radio Button that I selected stays selected when changing Activity. And how can I edit a TextView from, say, Activity1 when the Label is on Activity2, or the same with variables?

Thanks.

user959631
  • 1,004
  • 2
  • 14
  • 34

1 Answers1

1

I think you should write handler for this in onSaveInstanceState function.

Use the discussion here: Saving Android Activity state using Save Instance State - to find an answer.

Community
  • 1
  • 1
Belurd
  • 772
  • 1
  • 13
  • 31
  • Hi, Thanks for the reply. I couldn't get this to work but found an alternative, well I just didn't understand the link, and I had already seen the link before, but thanks again anyway. And the alternative is alot easier. BTW I forgot to mention I am a nooby at this, just started. hehe. =] – user959631 Dec 05 '11 at 23:20
  • Just realised that when you press the Home Key, the app is killed, and not minimized. So when I start the app again, the radio buttons are unchecked and I'm back where I started =[. – user959631 Dec 05 '11 at 23:50
  • I think you need to read a bit more about saving application state in Android. I had no problem like this, that is why it seems pretty clear and easy for me =) Good luck! – Belurd Dec 06 '11 at 00:09
  • Hehe, got another better way to do it, don't really need to mess about with saveInstance. Even when you press Home button, and open the app again, the settings are saved =]. Thanks for the help. – user959631 Dec 06 '11 at 20:32
  • So, what was your way to do it? Just write a bit about it. It could help someone else afterwards! – Belurd Dec 06 '11 at 21:48
  • Well, you have two RadioButtons, and want to see which one is checked, well you could write to a text file, with your reference of what radio button was checked. EG, RadioButton1 is checked, so write to the text file 'RadioButton1', then also read from it, so when the Activity starts, it checks if the file exists, and if it does, read it, and assign the value to a variable, then an If to check which RadioButton was checked, if the variable says 'RadioButton1' then RadioButton1.Checked = true otherwise if it says 'RadioButton2' then RadioButton.Checked = true, lol quite sloppy but does the job – user959631 Dec 06 '11 at 23:47