Can't set text on Dynamic Button "On App Resume"


I can’t seem to be able to “set text” on the button (Button is textless) “On App Resume”. Even though, the Card View and Button was created just fine.
Can you spot what I did wrong?
Please help.

Make sure you set a Text Color too, otherwise text may be hidden.

Also, I can recommend my extension which is a full dynamic components implementation.

1 Like

Wow. The Legend of Dynamic components! That’s an awesome extension! I saw it a couple of days ago. VERY Cool!

By the way, I tried as you suggested, no luck. I thought of it before, but when it is a button click that creates the dynamic button and sets the Text, there is no problem. By default the text is white. Is it a bug? I am not sure if my other codes interfered with it. But I thought it unlikely. What do you think?


I must revise what I said, this time, I use a button click to set the text of the Button. It won’t work also. I used to use a text dialog to retrieve the button text, and it worked fine. Any ideas? Is it because it is in a “for each”?
What do you think guys? Does this qualify as a bug? Any possible workarounds?

Do not use @ for getting attention as said by Peter

I apologize. I didn’t know that was not allowed.


yusufcihan, where do I find the “set button.text of component to” block? I already added a button to designer and made it invisible. But I still can’t find that green colored block from the block options related to “DynamicComponents1” or “new button”.

Also, if I replace the 'VerticalArrangement1" with the blocks on the right, it produces an error. Is this normal? I am trying to put the created component inside the Dynamic_Card_View1, but I can’t do that.

The answer itself is present in the screenshot you posted :point_down:

To be precise , from your project’s block section :point_down:

May be because the in socket there is expecting a layout name directly in which the component need to be created, instead of the dynamic component you are trying to assign indirectly with help of id parameter

2 Likes

Actually no. CardViews are layouts also. What is inside in ActivityID2? Probably there is a problem with your logic. You can test it by creating simple project to check if CardViews are accepted.

Actually it accepts every type of layout. So layout can be referenced from a variable. :slightly_smiling_face:

Also @yulius can you connect your app to the companion and right click on blocks and use “Do It” feature, this allows us to see the values of variables in the realtime, otherwise can you provide an AIA which reproduces this bug?

Lastly, why you are trying to create dynamic component on app resume? There can be a possibility to most components didn’t initialized yet.


Hi yusufcihan, the error I got is:
“Runtime Error
Couldn’t create a component, make sure component name is correct according to AI2 sources and check your Logcat for details.
Note: You will not see another error reported for 5 seconds.”

As you can see in the picture, “DynamicActivityButton.create Button” also uses the “call Dynamic_Card_View1.Get Card View By Id” block for “arrangement” and it works just fine to create a button. Though, as I’ve described earlier, I have no luck setting the button text. Which I am able to do using your extension, if I use the “Vertical_Arrangement1” block. But once, I change it to the “Get Card View By Id”, the aforementioned error occurred.

“ActivityID2” is only used there in that picture. It is an element of a sublist inside the list ActivityDB.

The app I am making require dynamic components. It is for my own use.

Looks like Kodular’s Dynamic CardView component can’t be not used together with my extension (Because it returns DynamicUtil but my extension expects a exact component) can you try creating CardViews with my extension too? Use “MakeroidCardView” as componentName to create a CardView.

Because as I can see from Do It result, it doesn’t return a CardView, it returns something different.

1 Like


Now I am using your extension to create both card view and button. The format is a little different-- “get global ActivityID2” can only be used once. So, I used your GetId block which works fine.

However, I still did not manage to put the button inside the card view created by your extension. Any advise on how to do this?

By the way, there is this error also:
"
Runtime Error
Property setter was expecting a com.google.appinventor.components.runtime.Button component but got a MakeroidCardView instead.
Note: You will not see another error reported for 5 seconds."

Yeah because all created components are saved in same memory. ID is unique, so you can’t use same ID for creating another component. For example,

Button - 1
CardView - can’t be 1 again, because it is used.

However you can multiply the ID with 10, so you won’t able to use same ID.

Button - 1
CardView - 10

Or you can add another DynamicComponent instance to the Designer. So both will have separated memory.

Use GetComponent block and connect it to “in” parameter. It returns the component from id. Just type the CardView’s id and it will work.

Because you are tying to change Text of CardView instead of a button, so there is no Text property in CardView. It will be gone when you fix duplicate ID error which I explained in above.

1 Like


Awesome!! It works!!

I use a lot of kodular’s dynamic components in my project. Can you please tell me the “words” to make labels, texts et cetera?

Label is “Label”
Textbox is “TextBox”

There is a list of components which you can create, (doesn’t include Kodular specific components).

File names presents component names.

I don’t have a %100 list of component names because they are a lot, and this extension allows creating hidden/beta/experimental components.

I see, only “CardView” is a little different then (MakeroidCardView)? I am a newbie, forgive my ignorance, there is a list of links in the github link you gave, which link should I click on exactly?

CardView is only specific to Kodular. The link I gave was App Inventor’s component list (which Kodular based on).

You just don’t need to click anything after going to the link, you will see a lot of files in the folder, all file names represent their component names.

I mean if file name is TinyDB.java, then component name exactly is “TinyDB” (case sensitive)

Just type the name of file in the componentName section.

1 Like

I see, I just realized I asked a stupid question Hahaha. Sorry. But thank you. Your extension is awesome. Hopefully, I can use it fully for my purpose.

I realized the reason why I cannot set the texts of the buttons, was because I am using the same name “ActivityButton” for the newly created dynamic buttons (even though the old "ActivityButton"s has been deleted from the screen), as the one in other blocks.
Strangely enough I can create buttons without any problems, I just can’t set their properties. Your extension works to set texts because it is not creating the same “ActivityButton”. But do you think that after deleting the card views with the buttons inside of them, I can still change the properties of the newly created buttons with the same name?

Yes and no.

I mean, you should delete the Button in the CardView first, and then delete CardView itself, because it will delete the CardView with components inside, all of them will be gone from screen. But ID still will kept.

So delete all components in CardView then delete the CardView itself.

After that you will able create new components with using same ID.

1 Like

I see! I will try that. Thank you so much for your tips. I thought it was a bug. Why can I create a button but cannot set the text of the button right below it. Perplexing. But let me try your suggestion. Thank you.

1 Like