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 making a full method to create all dynamic components without creating different blocks for every component because 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.
There are some projects from other people on the community that use the Dynamic Components extension. Just mention me, PM me, or link this topic in your topic to get your project showed listed here!
- Dynamic CardView Template - Kanishka_Developer
- Horizontal Dynamic Layout - Deepanshu Arya
- #CinelarTV, a digital streaming platform - Alexander
- To-Do List | Using Dynamic Components - Soham Shah
- Educationaly - Ravi Garg
- 5 Different Listview Using Dynamic Components - Maayur Berad
Note that these projects belong to their original posters.
com.yusufcihan.DynamicComponents.aix (16.4 KB) (v1.3)
Looking for old releases and changelog? Check it from here.
You can report bugs, download old releases, contribute the code and do more from the repository!
You can post in topic for help, a question about this extension, or PM me anything about you want to talk!
- Yusuf Cihan