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
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.
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
When you drag from component it will be get component.
Yes! Thatās what Iām saying. Does getComponent() return the ID only? LOL! Iām feeling like a noob
EDIT 1:
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
EDIT 2:
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:
- Enable click option on the the Dynamic Labels.
- 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.
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
@WatermelonIce I think I should better use Dynamic Button and making the background color as transparent. That would be easier
@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
Ohh you are faster than me. I have started build now. Appybuilder editor takes 5 minites to build