OnClick method for Dynamic Label

As the name above suggests, I request the Kodular developer team to provide an OnClick() option for Dynamic Label. As I am stuck in a condition where I need to fetch the ID of a Dynamic Label from a set of Dynamic Labels with randomly generated IDs. Also if is it possible in any another way, please provide a set of blocks as an example. TIA :slight_smile:


You can use when any label.clicked
As I remember it exists.
Then, if component=get label components by ID,
(Your action)


Or if you want to get the ID, Simply use the get ID from ‘get component’

I appreciate your quick response. But what I am actually trying to say is, that I want to fetch the ID of a Dynamic Label. The Dynamic Labels are generated according to the data available in the dB so I don’t know how many Labels are created and neither do I have their IDs(at the time of coding). I want a block which provides me the ID of the label that user has clicked so that I can delete that label from the list. I hope I’ve made my doubt clearer to you. :slight_smile:

1 Like

Could you please give a block PNG for get component. My previous reply got accepted after yours. LOL!


It is a variable dragged from ‘when.any label clicked’.

All I can see in when any Label.Click are 2 variables namely component and not already handled An example would be appreciated :slight_smile:

When you drag from component it will be get component.

1 Like

Yes! That’s what I’m saying. Does getComponent() return the ID only? LOL! I’m feeling like a noob :stuck_out_tongue:

When I’m trying to use the getComponent result as an ID the following error is shown. That is why I was asking for if by any way can we fetch the ID of Dynamic Label

This is a Snippet of my code. Ignore the red crosses (errors) those are caused since I created a new screen and copied these blocks without adding them. I hope this will help you understand it better that why I require the ID of Dynamic Label since the getComponent is returning a non int value and causing the above error.

EXPLANATION: I am fetching a dictionary from firebase dB and creating dynamic labels for all the keys and values(not in the blocks).

I want to:

  1. Enable click option on the the Dynamic Labels.
  2. Delete the Label which is clicked.

PS: I tried using ListViewer for the same but it displayed values in the following format (key, value) on which when I applied the click event I was not able to fetch the key name since it contained brackets and commas. Any help for the stated would be appreciated and thanks for bearing with me till now. :see_no_evil:

1 Like

No, get component doesn’t return the number, but the component instead.

And you cannot get ID by clicking the label.
If you need to the you have to use the extension by @yusufcihan

1 Like

@WatermelonIce I think I should better use Dynamic Button and making the background color as transparent. That would be easier :smile_cat:

@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();

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

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


1 Like

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


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:


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

Here is my one

But ken won