Checkboxes Reset

140 views
Skip to first unread message

tku...@gmail.com

unread,
Mar 4, 2014, 5:21:56 PM3/4/14
to mitappinv...@googlegroups.com
I am using checkboxes on a few different screens. When I go to a screen and check a checkbox (or set it to true) it works just fine. Now if I want to go to a different screen and then come back. My checkboxes, which I checked previously, are no longer checked. I would like to them to remain checked until the user clicks the reset button I created. How do I keep them from resetting when changing screens? Thanks!

Enis

unread,
Mar 4, 2014, 6:24:19 PM3/4/14
to
You really have to save their states (checked or un-checked) before you leave a screen, and then in the Screen.Initialize block, restore those items when a screen is loaded again.  You have to be careful about persistence in Android programming as there's a life cycle for screens, and the operating system can destroy an unused screen at any time.

You should use a TinyDB for persistent values.  It's easy to use, and perfect for storing pairs of data lie "checkbox1", "True" or "Checked" or 0/1.

Taifun

unread,
Mar 4, 2014, 6:50:25 PM3/4/14
to
Now if I want to go to a different screen and then come back.
My checkboxes, which I checked previously, are no longer checked.  
as you can see, this does not work together with the AI Companion app,
however after building the app, this works... use the close screen block to come back...
Taifun

tku...@gmail.com

unread,
Mar 4, 2014, 6:54:56 PM3/4/14
to mitappinv...@googlegroups.com
On Tuesday, March 4, 2014 6:50:04 PM UTC-5, Taifun wrote:
> Now if I want to go to a different screen and then come back.My checkboxes, which I checked previously, are no longer checked.  
> as you can see, this does not work together with the AI Companion app,
> however after building the app, this works... use the close screen block to come back...
> Taifun

Ok Thanks!

tku...@gmail.com

unread,
Mar 4, 2014, 6:56:12 PM3/4/14
to mitappinv...@googlegroups.com
On Tuesday, March 4, 2014 5:30:24 PM UTC-5, Enis wrote:
> You really have to save their states (checked or un-checked) before you leave a screen, and then in the Screen.Initialize block, restore those items when a screen is loaded again.  You have to be careful about persistence in Android programming as there's a life cycle for screens, and the operating system can destroy an unused screen at any time.
>
> You should use a TinyDB for persistent values.  It's easy to use, and perfect for storing pairs of data lie "checkbox1", "True" or "Checked" or 0/1.

Thanks Enis, good thing my livelihood does not depend on me building apps.....I'd starve!!

Enis

unread,
Mar 4, 2014, 7:21:48 PM3/4/14
to
You'd starve until you learn how to do it lol!  I've attached a quick project... it does what you want in a minimum of blocks...

Download this project.
Click on My Projects
Then click on Project
And choose Import project (aia) from my computer
Then run it on the emulator...

Come on back and let us know how you and we did!

Don't hesitate to ask questions Tom... that's what we're here for!

BTW, Taifun's correct... it works normally the way you had it if it's running as an App (apk) on the device.  This is a good exercise in saving states and data...
ForTomCheckboxes.aia

tku...@gmail.com

unread,
Mar 4, 2014, 7:31:35 PM3/4/14
to mitappinv...@googlegroups.com
Outstanding! I will work with it later in the week. I have to quit now do some other things. I will let you know how I make out. I am a GIS Analyst and I really want to learn how to program, but I am not a very logical person it seems. I guess if I work with this long enough I will start to understand. And thank you very much for taking the time to do this for me. Again I will post my results when I work with it again. I have a job interview on Thursday, so I may not get back to it until Friday, but I will definitely post to the forum.

tku...@gmail.com

unread,
Mar 17, 2014, 6:23:03 PM3/17/14
to mitappinv...@googlegroups.com
Enis thanks for the help. I just got to work on it a bit today and it's working. The emulator is really slow. I have a slow internet connect where I stay near my work. At home it is much faster, but don't get much time to work on it there. I have a much better handle on it now. THANKS! It's great to have like all of you to help us. Happy Saint Patrick's Day!!!!!

Enis

unread,
Mar 17, 2014, 6:24:30 PM3/17/14
to mitappinv...@googlegroups.com
Luck 'o the Irish to ya!
Reply all
Reply to author
Forward
0 new messages