问题
I'm trying my best to learn App Inventor2. Although I'm a little familiar with coding in Java with Eclipse and Android Studio and I'm aware of App Inventor limitations, I like most, the graphical interface and the visual objects, than developing an app all the way in code.
I'm having a screen in an app as the following image, that I need to achieve this functionality: a. User checks a "CheckBox" related to an image of their liking. b. User inputs some identification related (id1, id2) to this image. c. Clicks the "Save" button to store this values (checkBox, id1,id2) to a TinyDB. d. Clicks the "Reset" button to clear info stored in TinyDB (checkBox, id1,id2).
I know that TinyDB can only store text. I have tried to make a TinyDB with a tag as a list named "idList" and have it populated with the values from "checkBox", "id1","id2", without success. I believe that I'm knot checking weather the "checkBox" changed or something like that.
Can someone be kind enough to point me to the right direction following this logic, or point me to something better if I'm wrong?
Thank you all in advance for your answers.
回答1:
in the button click event you need some logic to find out, which checkbox has been checked, something like this (pseudocode)
if checkbox1.checked then store the text 1,
elseif checkbox2.checked then store the text 2,
etc.
in TinyDB
you can store a list with the result of that logic and the text from the textboxes like this
also you have to read the values from TinyDB
again. Normally you do this in the Screen.Initialize
event, example:
in case you do not like the advanced blocks, you can do the same with some regular blocks, too...
See also
- How to work with Lists by Saj
- How to work with Lists and Lists of lists (pdf) by appinventor.org
来源:https://stackoverflow.com/questions/29334456/how-to-build-a-tinydb-with-values-from-checkbox-and-textbox-in-app-inventor2