Help in making extension needed

Dear all,

I have started learning of making extensions last week.
I am successful in making small extensions like mathematical functions.

Now i want to make dynamic components and append different functions to their events.

I implemented the following code and created a button in runtime successfully.

package io.Testing;


@DesignerComponent(version = 1,  
					description = "Testing",
					category = ComponentCategory.EXTENSION,
					nonVisible = true,   
					iconName = "images/extension.png")

@SimpleObject(external = true)
public class Testing extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    public Testing(ComponentContainer container) {
        this.container = container;
	@SimpleFunction(description="Add a new button.")
	public void AddButton(){
		Button myButton = new Button(container);
		myButton.Text("New Button");

Now i want to implement Click event to this button.
Please help me in doing this.

Waiting for quick replies.

Thank you.

Hema Srinivas

I don't know how other extensions accomplish this, but likely the easiest thing to do would be to call Button.getView() to get the underlying Android view, cast that to an android.widget.Button, and then call setOnClickListener to add your own click listener. This will override the listener attached by App Inventor.

1 Like

You received an answer to this question over a week ago in Kodular Community.

1 Like