Hi, I want to introduce my new extension which allows creating components dynamically!
But, you may ask;
“There is an already bunch of different Dynamic Components extension, why did you create another one?”
Because this one is different!
I thought about a full method to create all dynamic components without creating different blocks for every component, but it would be useless. So I was trying to find a proper solution for a long time. And here it is!
It basically uses Java’s Reflection feature, so this allows you to create ANY component you want dynamically which added to App Inventor (includes Kodular components too if you use Kodular). Not only a
Button, but you can also even create a
DatePicker dynamically. Just type the component’s name which you want to create, that’s it!
What is the reflection and how does it work?
Reflection (in programming) allows you to modify the program during runtime, for example, you can create a new Class, Method, etc. and search them by its names!
Basically, it appends
componentName parameter to the
com.google.appinventor.components.runtime. text and creates an instance of it. When you type “Button”, it searches for Button class and creates an instance of it.
So with this method, it is now a fully implemented dynamic component extension.
I must say Java is a powerful language
How can I set the properties for the blocks?
You have two options and both does the same job:
How can I delete all components?
Use a for-each loop for that.
com.yusufcihan.DynamicComponents.aix (13.4 KB) (v1.2.1)
Looking for old releases and changelog? Check it from here.
You can post in topic for help, a question about this extension, or PM me anything about you want to talk!
- Yusuf Cihan