H Hirogens Active Member Licensed User Longtime User Aug 16, 2018 #1 Hello, I use a calendar and when I click on a special day I load all the activity create this day. I would like to create X label ( if I have 5 activity I create 5 label) And when I click on a label I would like to show all the information about this activity. I already have everything but I don't know how to create the labels with _Click function for each label. How can I do that ? Thanks
Hello, I use a calendar and when I click on a special day I load all the activity create this day. I would like to create X label ( if I have 5 activity I create 5 label) And when I click on a label I would like to show all the information about this activity. I already have everything but I don't know how to create the labels with _Click function for each label. How can I do that ? Thanks
LucaMs Expert Licensed User Longtime User Aug 16, 2018 #2 Hirogens said: How can I do that ? Click to expand... Reading abc. https://www.b4x.com/android/documentation.html Upvote 0
Hirogens said: How can I do that ? Click to expand... Reading abc. https://www.b4x.com/android/documentation.html
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Aug 19, 2018 #4 Hirogens, If I understand your question correctly. You were asking how to handle events from an unknown number of views that are created in code. The way I would do this is to create all of the labels with the same event handler. I would then use the tag on each label to hold an identifier for each created label. Code: Copy ' Create the labels For i = 0 To numberoflabels lbl.Initialize("CreatedLabels") lbl.Tag = i ' Code to place label in Activity etc Next then Code: Copy Sub CreatedLabels_click Private lbl As Label = Sender Private clickedLabel As Int = lbl.Tag Log("Clicked Label "& clickedLabel) End Sub If you need to store more data against each label you can store a map in the tag which could then have an ID field. Hope this helps Upvote 0
Hirogens, If I understand your question correctly. You were asking how to handle events from an unknown number of views that are created in code. The way I would do this is to create all of the labels with the same event handler. I would then use the tag on each label to hold an identifier for each created label. Code: Copy ' Create the labels For i = 0 To numberoflabels lbl.Initialize("CreatedLabels") lbl.Tag = i ' Code to place label in Activity etc Next then Code: Copy Sub CreatedLabels_click Private lbl As Label = Sender Private clickedLabel As Int = lbl.Tag Log("Clicked Label "& clickedLabel) End Sub If you need to store more data against each label you can store a map in the tag which could then have an ID field. Hope this helps