Handling (change state, for example) a list of checkboxes and using Firebase

Hello!!! I hope to be asking in the right place, anyway I apologize in advance if I say something stupid.
So, I’m building an app with a list of checkboxes [listChb] aggregated into categories (8 checkboxes in 10 different categories, totaling 80 checkboxes, all of them will always be in the same order to help handling the names and states (true or false)). The state of each checkbox is saved in the list and then sent to Firebase under the tag day_month_year, so I can redeem the checkboxes that were marked or not in any other past day.
Here is where I’m stuck:
After changing the status of the checkboxes from FALSE to TRUE, I would like to know if there is a way to do a “when any checkbox.changed” and give a “replace” command in my checkbox list [listChb], by setting automatically the checkbox index to be replaed based on the checkbox that I changed.
I already created the first 8 buttons and in each one I inserted the function “replace list item” when the state is changed, manually informing the list index for the changed checkbox and sending the list to Firebase, but I don’t think this is a good programming practice and I would like to find out if there is a way to improve the handling of these checkboxes.

Attached I send the blocks I have so far.

PS: I tried to use a solution that I read from @bodymindpower in the post How to Share MP3 From my Playstore App but I was not successful because I did not understood the logic.

Thank in advance to everyone and anyone who can help. :slight_smile:

see how to use the advanced blocks here App Inventor Tutorials and Examples: Checkbox | Pura Vida Apps

Taifun

Thanks Taifun, I’ll test it and get back here :slight_smile:

Hi!

I tested the “when any Checkbox.Changed” but the following error message appears to me:

The operation replace list item cannot accept the arguments: , [(com.google.appinventor.components.runtime.CheckBox@50075c6 com.google.appinventor.components.runtime.CheckBox@238a987 com.google.appinventor.components.runtime.CheckBox@b3180b4 com.google.appinventor.components.runtime.CheckBox@882d4dd com.google.appinventor.components.runtime.CheckBox@c7e2852 com.google.appinventor.components.runtime.CheckBox@36c5723 com.google.appinventor.components.runtime.CheckBox@fbff420 com.google.appinventor.components.runtime.CheckBox@1dce1d9)], [com.google.appinventor.components.runtime.CheckBox@50075c6], [true]
Note: You will not see another error reported for 5 seconds.

I think I’m missing the point of “any checkbox” and/or “for each checkbox do” :confused:

Here are the blocks that I tested trying to make the app work, unfortunately none of them worked.

blocksWaC.C3 blocksWaC.C2

Hi Taifun!
I think I’ve managed a way to make it but I don’t know if I get it straight.
In the beginning I was trying to change the state of checkboxes in a list that where filled with checkboxes, but the state of a checkboxes is a boolean, right?
After that I realized that I should have a list of booleans [lsBoolean] with the same lenght of the list of checkboxes [lsChb], so I could get the state (true or false) from the “lsBoolean” and set the values in the “lsChb” using the same index.
I’m sending the block so maybe you could analyze it and give your opinion, if I’m not asking too much.
My next step is to learn how to handle the lsBoolean so I don’t have to make 2 lists with 80 components each

blocksWaC.C4

yes
your screenshot is too tiny to see anything…
please upload screenshots like this
add.screenshot
Taifun

Sorry Taifun, wich one of the screenshots you can’t see? The ones in the first post or the one in the last post?

just check the screenshots yourself… those which are not clickable are the tiny screenshots…
the first 2 from the first post and the screenshot from the last post…
strange… my own screenshot also is not clickable… what is going on?

Taifun

When I’m using my smartphone I can open the images but in PC I have to right-click them and select “open image in another tab”.

Anyway, here we have a screenshot of the blocks with the implementation of “when any Checkbox.Changed” that is working. I would really appreciate if you could tell me if I am in the right way by using two lists, one for checkbox [lsChb] and other list for each state of the checkboxes [lsBoolean].

Many thanks in advance, Taifun!

I did this, which results in a very tiny not readable image

this looks good…

let me suggest you to reuse these 8 checkbox components rather than creating 80 checkboxes… you could add a global variable category to identify the category and change the text of the checkboxes dynamically…

DRY - Don’t repeat yourself…

Taifun

Taifun, thank you a lot for your time!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.