OnClick method for Dynamic Label

@ExtensionDevelopers whoever can do this, since I don’t have time to… just compile and leave the AIX in this topic.

// ...
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
// ...
@SimpleFunction(description = " ")
public int GetIdByComponent(AndroidViewComponent component) {
    return component.getView().getId();
}
2 Likes

Build failed


Note: I don’t know about extension developement, so if any changes are to be made then guide me.

You have removed all code of editor

@FlailingOctopus told that compile this code so I delete all that. :grimacing::grimacing:

🤷:grin::grin::grimacing:

1 Like

com.appybuilder.kennicholsandroid.GetComponentID.aix (5.5 KB)
GetComponentID.java (1.4 KB)

4 Likes

Ohh you are faster than me. I have started build now. Appybuilder editor takes 5 minites to build :weary::weary::weary:

1 Like

I was driving or I would have uploaded it sooner:

5 Likes

com.appybuilder.vedangsolaskar2018.ExtensionCodeByStormi.aix (5.8 KB)

Here is my one

But ken won

2 Likes

Thank you so much for the code. But I guess, we still don’t have a method for whenAnyDynamicLabel.Click() also I may be wrong but whenAnyLabel.Click() won’t give you component for a click on Dynamic Label. Please let me know if I’m wrong with a suitable block, if possible.

Also thanks to @Ken and @Vedang for the quick compilation of the give code but while using the extensions following error is generated. If any further help could be provided that would be great although I did my work using Dynamic Button but since this could be a useful feature for future.

3 Likes

I thought you wanted the label to be clicked? Here you use the Dynamic Button however it likely will reproduce the same issue :thinking:

Let me take a look into the issue in the next few minutes and I will get back to you.

2 Likes

Yes! I wanted the label to be clicked. But couldn’t found whenAnyDynamicLabel.Click() Therefore just for the testing the extension, I used the Dynamic Buttons. Also as you said the error would be same in both case. Also try adding a whenAnyDynamicLabel.Click() so that we can test the above extensions on a Dynamic Label.

1 Like

No need to test since the dynamic label is composed of MakeroidDynamicLabel like MakeroidDynamicButton :) What I’m doing now is creating my own dynamic label and button extension, they will both contain the method you need.

@yusufcihan I know what you going to do, mention your extension (:

1 Like

I don’t like self-promotion but you should use my extension for that. So you won’t need to deal with using extension over a Dynamic Label component.

So you can create dynamic Labels along with other all components and use Any Component blocks if you want to set its properties and catch the events.

image

If you have a better option, go for it. I just provided an another way (and easier maybe? :slightly_smiling_face:).

4 Likes

Nooooooo, you were typing and then it reminded me of your extension :slight_smile:

1 Like

That is an awesome extension @yusufcihan Thank you everyone for your time guys. I’m leaving an example blocks below (for future reference) which Dynamically creates Labels and changes size and text when a Button is clicked. :slight_smile:

1 Like

Thank you :grin: By the way, I recommend using SetProperty block only when there is no Any Component block for the property. Because it is currently causing a problem on < Android 7 (currently fixed / waiting for next release).

image

2 Likes

Ok I’ll keep that in mind! :ok_hand: Thanks :smiley:

1 Like

Actually I have suggested already.

1 Like

Yup I know! But that time I wasn’t able to understand the use of the extension. :sweat_smile: Thanks btw :smile:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.