TinyDB: store and get more than one index value from a List (ColinTreeListview)

Hi guys! I hope you are all doing great! I'm new to App Inventor and to programming in general.

I've been doing some small demo apps to learn my way into the blocks and stuff. Right now I'm trying to understand how TinyDB works. I've created a demo app, it's just a list of text (5 items), each item has its own button (ON - OFF). I managed to save each time the text of a button and the color of the button changes but I can't seem to be able to respect the position (I believe that's called "index") of such changes.

What do I mean by that? Well, let's say that I click the button of item number 3 so the text color and the text itself (of the button) change to their new state... That works great! Next I call TinyDB to store my value. I can store the color information and the text information BUT I can't store the index information. I have been able to store the LastClickedItem, or a fixed position (the one a set in the variable) but I can't store all of the buttons that have changed.

Can you help me see what I'm doing wrong? I image my mistake is around the "index" info but I don't know.

I'm including the blocks and the project in case any of you want to check it out.

Thanks in advance! Martin!

PS: I'm using the extension ColinTreeListView (but a modified version by GustavoFernandez, he shared it in the thunkable forum). He said he added: Text color for all ExtraButton, Separate text color for each ExtraButton in the list, and Independent background image for each extrabutton in the list to the extension.

blocks(2)

blocks(3) blocks(4)

DemoProjectTinyDB.aia (51.9 KB)

Try this:

DemoProjectTinyDB_revised.aia (53.2 KB)

I am not sure if you wanted to use the "ERROR" text in Blue as well, if so, then you need to add an elseif to the Element Click event and set the text and colour in the same way. That way you have a three way click event ERROR/ON/OFF

You may want to read up on using lists:

Learn about using lists:

General Tutorials

2 Likes

OMG Tim!!! Thank you so so much!!! I have just tested it and that's perfect. I will study the blocks that you used and I'll check those links as well. Again, thank you very much for your help. :smiley:

I needed some respite from my current project :wink:

1 Like

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