如何使用App Inventor2中的CheckBox和TextBox创建TinyDB? [英] How to build a TinyDB with values from CheckBox and TextBox in App Inventor2?

查看:1656
本文介绍了如何使用App Inventor2中的CheckBox和TextBox创建TinyDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尽力学习App Inventor2。
虽然我对Eclipse和Android Studio的Java有些熟悉,我知道App Inventor的限制,我喜欢大多数图形界面和可视对象,而不是开发一个应用程序代码。



我在应用程序中有一个屏幕作为下面的图片,我需要实现这个功能:
a。用户检查与他们的喜好的图像相关的复选框。
b。用户向该图像输入一些标识相关(id1,id2)。
c。单击保存按钮将此值(checkBox,id1,id2)存储到TinyDB。
d。单击重置按钮以清除存储在TinyDB(checkBox,id1,id2)中的信息。





我知道TinyDB只能存储文本。我试图做一个TinyDB与一个标签作为名为idList的列表,并使用checkBox,id1,id2的值填充,没有成功。我相信我结天气检查复选框改变或类似的东西。



有人可以告诉我这个逻辑正确的方向,或者指出我更好的,如果我错了?



感谢您提供的答案。

解决方案

按钮点击事件你需要一些逻辑来找出,哪个复选框已被选中,类似这样的东西(伪代码)

 如果checkbox1 .checked然后存储文本1,
elseif checkbox2.checked然后存储文本2,

TinyDB 中,您可以存储一个列表,该逻辑的结果和文本框中的文本如下



>



也必须再次从 TinyDB 中读取值。通常,您可以在 Screen.Initialize 事件中执行此操作,例如:





如果您不喜欢高级块,可以




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.

解决方案

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

这篇关于如何使用App Inventor2中的CheckBox和TextBox创建TinyDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆