Button creation extension

Is there an extension that creates multiple buttons? The condition is that the created buttons can be operated in the same way as in appinventor. So that i can hide them, unhide them, change colors without having to recreate all buttons.

When you search an extension you should always look here.

https://puravidaapps.com/extensions.php

1 Like

Here an extension (2017)

Yes, I checked there and I did not find one that meets this condition, unfortunately.

With this extension we will not hide the button, we will not change the color, etc. I have to unfortunately remove all buttons and recreate. Also, I cannot use a percentage of the size.

Will this do it:

3 Likes

The description looks great. I have to test. I didn't find it because I was looking for word "create". Thanks.

Here is a simple example

demoDCButton.aia (16.9 KB)

It is important to increment the id!

1 Like

Thanks. I also read about creating elements using a json file. I understand that first I need to build a real layout of elements and then use the schematic generator to generate json? I have an extensive application and resources are slowly running out. I have to struggle to avoid getting a DX error. This extension could save a lot of resources.

Yes if you look at the show case in the link, Maayur makes five different listviews, and these each have a schema written as well. For complicated layouts this can save many blocks.

I checked your aia file. You used "set property" from the extension there, but it also works from any components "set button font bold" blocks. Great extension. I added hiding buttons in "any button click" block, it works great. The only question is whether if we put many button events in "any button click", it will not delay the response to the button? Thanks to the ID, we can perform the same operations in a loop on many elements without having to create lists of components. Great ...: D

I put both in there because if you join a string it doesn't work with the property setter (you have to use the anyComponent)

Have you ever used a template?

Tested with Companion (results in milliseconds):

Yes, Anke. I also saw such measurements made by the developer of this extension. But I mean something else. I use google translator, so what I am writing may not be very understandable :). Building 100 buttons is one thing. However, later you have to handle these buttons. Pressing a button does something. All 100 buttons must be handled in one block "any button click" with "if". If we press a button that is at the very end in the "any button click" block what will be the delay?

Yes, interesting question, it's best to just test it.
But I think as long as there are not much more than 100 buttons, the delay should be bearable.

Further to to enquiry about colours and setting properties with the dynamic extension:

  1. The Dynamic extension only accepts the android colours (either the colour blocks or colour numbers)
  2. The Dynamic extension may not accept the property setter for all settings, in which case use the anyComponent block instead.
  3. Colours could do with some "unification" given that we have to use hex on the designer, rgb to make a colour, and android colour numbers elsewhere......
  4. Setting properties in AI2 can be a little quirky at times. You set "enabled" with a boolean true/false, and if you ask for that property back it gives you back a boolean true/false (no quotes) not a text true/false. Setting a "fontsize" requires a number (Maths) block, and returns a number (no quotes). These may need to be converted to a string in the SCM file for a reason, but in the app, they will be treated as their original type.

From what I have tested the templates, this extension accepts all the properties that are saved in SCM. The json generator only bypasses uuid and version. In the SCM file, all values are stored in "" as a string. Well, wanting to use the generated json with the "Schema" block, we have an error in the application. Likewise, appinventor saves the colors in the SCM file as RGB and adopts them as android. No sense...Now, in order for the "schema" block to work, you need to convert all colors to android colors, and remove all quotes from numerical values and boolans. I reported a problem on github, I think the author will improve the template creator for appinventor because it works fine in kodular. It's almost working fine. However, it does not accept the longer 64bit values, only the shorter 32bit :slight_smile:

It seems to be fixed:

Yes. These are my submissions. We're still struggling with it. There is a little mistake but it's almost ok :).