DynamicComponents 拓展
.aix 拓展下载:
com.yusufcihan.DynamicComponents.aix
完全支持 App Inventor 2 的动态组件扩展。它基于 Java 的反射功能,因此只需键入类名称即可搜索类来创建组件。因此,它对特定组件的支持不受限制,因为它支持添加到 App Inventor 发行版中的每个组件!
此扩展可以根据你的选择异步或同步创建组件。
如果你不想在创建一堆组件期间阻止主应用程序,请转到设计视图(导入扩展后)并在“UI”(异步)和“Main”(同步)之间进行选择。
代码块 | 描述 | ||||||
---|---|---|---|---|---|---|---|
创建一个新的动态组件,它支持添加到当前 AI2 发行版的所有组件。
组件名称 参数可以是以下值:
|
|||||||
Changes ID of one of created components to a new one. The old ID must be exist and new ID mustn't exist.When replacing an ID, it will loop through ALL IDs and replace each one that contains the old ID! Even if the ID you're wanting to replace is "Timmy", but there are IDs like "Timmy-truck". To be clear again, only "Timmy" from "Timmy-truck" will be replaced, the "-truck" part will stay the same! |
|||||||
Creates components from JSON string. Refer to the Wiki about creating your own templates. | |||||||
Removes the component with specified ID from screen/layout and the component list. So you will able to use its ID again as it will be deleted. | |||||||
Set a property of a component by typing its property name. Can be known as a Setter property block. It can be also used to set properties that only exists in Designer. It works for common types. For other values, you should use Any Component blocks. |
|||||||
Same as SetProperty block, but for setting the properties with Dictionary. Dictionary keys equal to property names and Dictionary values equal to property value. |
|||||||
Returns the component's itself for modifying purposes.
ID must be a valid ID which is added with Create block. ID --> Component |
|||||||
Returns the ID of component. Component needs to be created by Create block.
Otherwise it will return blank string. Also known as reverse of the GetComponent block. Component --> ID |
|||||||
Gets the position of the component according to its parent arrangement. Index starts from 1. | |||||||
Sets the position of the component according to its parent arrangement. Index starts from 1. Typing 0 (zero) will move the component to the end. | |||||||
Moves the component to an another arrangement. | |||||||
Get a property value of a component by typing its property name. Can be known as a Getter property block. It can be also used to get properties that only exists in Designer. | |||||||
Get meta data about the specified component. | |||||||
Get meta data about events for the specified component. | |||||||
Get meta data about properties for the specified component. | |||||||
Get meta data about functions for the specified component. | |||||||
Returns the last component's ID. | |||||||
Returns all used IDs of current components as App Inventor list. | |||||||
Makes a random unique UUID. Use this block in Create block if component ID is not required for you. | |||||||
Returns 'true' if component has created by Dynamic Components extension. Otherwise, 'false'. | |||||||
Calls a method of any component. If the return value is not important for you, use with evaluate but ignore result block.
|
|||||||
Returns the version of the extension. | |||||||
Returns the version name of the extension. | |||||||
Raises after Schema has been created with Schema block. | |||||||
Raises after a component has been created. |
FAQ
-
如何设置块的属性?
有两种选择,效果一样:
SetProperty
或
Any Component
-
如何删除所有组件?
使用 for-each 循环:
-
如何制作自己的架构模板?
为扩展制作 JSON 模板:你可以访问动态组件存储库的 Wiki 部分,了解如何创建动态组件。
-
扩展是异步工作还是同步工作?
它是同步工作的。我在这篇文章中解释了为什么它同步工作。
现在你可以使用 Thread 属性在异步或同步之间切换!
-
应用程序需要花费大量时间来创建使用
图像
组件的组件,我该如何修复它?将现有的 Image.Picture 组件替换为 Image Utilities 组件。可以使用扩展来异步加载图像。
-
创建组件需要多少时间?
我创建了 10000 多个组件,并计算了需要多少秒才能完成创建。
基准测试结果
制作了一个测试应用程序,它创建了许多带循环的 Button 组件,并使用 Clock 计算执行时间。
测试1
平台:Companion / Kodular
测量方式:内置时钟组件
创建:具有默认属性的“按钮”组件
元件数量 | 创建时间(以秒为单位) | 创建时间(以毫秒为单位) |
---|---|---|
100 | 0 sec | 535 ms |
200 | 1 sec | 1387 ms |
500 | 3 secs | 3718 ms |
1000 | 6 secs | 6992 ms |
2000 | 12 secs | 12748 ms |
5000 | 36 secs | 36925 ms |
10000 | 73 secs | 73849 ms |
测试2
平台:导出应用程序/Kodular
测量方式:内置时钟组件
创建:具有默认属性的“按钮”组件
元件数量 | 创建时间(以秒为单位) | 创建时间(以毫秒为单位) |
---|---|---|
100 | 0 sec | 593 ms |
200 | 1 sec | 1079 ms |
500 | 2 secs | 2427 ms |
1000 | 6 secs | 6023 ms |
2000 | 12 secs | 12009 ms |
5000 | 25 secs | 25092 ms |
10000 | 64 secs | 64520 ms |
注意:
当然,当前运行的应用程序、当前可用内存、设备类型等都会影响执行时间。这只是一个大致的基准测试。