app-inventor - 循环设置点击按钮事件
问题描述
在我的应用程序中,有几个按钮具有相同的操作:
when button1.Click do ...
when button2.Click do ...
when button3.Click do ...
when button4.Click do ...
...
我可以在循环中为它们设置点击事件吗?
解决方案
您可以在每个按钮单击事件中调用相同的过程并将按钮 ID 作为输入参数传递
when button1.Click do
call myProcedure "1"...
when button2.Click do
call myProcedure "2"...
when button3.Click do
call myProcedure "3"...
when button4.Click do
call myProcedure "4"...
然后在 for each 循环中,您可以执行类似的操作(假设有 4 个按钮)并将当前数字传递给过程
for each number from 1 to 4 do
call procedure "number"
学习 App Inventor 的一个很好的方法是阅读 AI2 免费在线电子书 http://www.appinventor.org/book2中的免费 Inventor's Manual ...链接在网页底部。这本书“教”用户如何使用 AI2 块进行编程。这里有一个免费的编程课程http://www.appinventor.org/content/CourseInABox/Intro 和书中项目的 aia 文件在这里: http://www.appinventor.org/bookFiles
如何做一个此处描述了 App Inventor 的许多基本内容:http: //www.appinventor.org/content/howDoYou/eventHandling 。
还可以通过教程http://appinventor.mit.edu/explore/ai2/tutorials.html来学习 App Inventor 的基础知识,然后尝试一些东西并遵循Top 5 Tips: How to learn App Inventor
推荐阅读
- function - Oracle 函数返回 CHAR
- angular - 更新到 angular10,画布图像混乱
- r - R ggplot显示弯曲最大值
- google-api - youtube 爬虫有收费配额吗?
- json - 如何从flutter中的单个json获取键列表和值列表
- memory-management - Redis 集群是否有可能拥有超过 256TB 的容量?
- r - 无法为签名“RasterLayer”找到函数“gui”的继承方法
- mysql - 如何根据另一列的特定列值过滤表?
- android-studio - 在“PATH”中找不到可执行文件。请确保已安装 Gauge。即使它安装在 windows 和 mac
- powerapps-canvas - 在列表 B 列 2 的值中筛选 SharePoint 列表 A 列 1 的值,而没有删除警告