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
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.
I thought you wanted the label to be clicked? Here you use the Dynamic Button however it likely will reproduce the same issue
Let me take a look into the issue in the next few minutes and I will get back to you.
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.
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 (:
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.
If you have a better option, go for it. I just provided an another way (and easier maybe? ).