Android Question Problem in Tag And Sender

™AsAs4242

Member
Licensed User
Longtime User
Hi : ))

i have a problem with tag and sender !

in my app create 8 label in loOp and set text and tag of labels = Count LoOp
(and create 1 edittext and 1 button for edit the text of label)


when click of the label with use of sender i have get tag clicked label and equals with edittext text !

i edit the text in edittext

i want when click on button the new edited text is equal to clicked label


this is my code :


and attached project!




B4X:
Sub Process_Globals

End Sub

Sub Globals
    Dim Element_Top As String
    Dim Edt_Edit As EditText
    Dim Btn_Edit As Button
    Dim lbl_Test As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.Color = Colors.LightGray
Create_Btn_Edt
Element_Top = 2%y


For i = 0 To 7
    lbl_Test.Initialize("lbl_Test")
    lbl_Test.Color = Colors.DarkGray
    lbl_Test.TextColor = Colors.White
    lbl_Test.Gravity = Gravity.CENTER
    lbl_Test.Text = i
    lbl_Test.tag = i
Activity.AddView(lbl_Test,2%x,Element_Top,96%x,7%y)
Element_Top = Element_Top + 9%y
Next

End Sub


Sub lbl_Test_Click
' When Click On label Created With LoOp Then -->     (  The Text OF Edit Text = lbl Created On lOop Text  )
    Dim lbl_Tag As Label
    lbl_Tag = Sender
    Edt_Edit.Text = lbl_Tag.Tag
End Sub


Sub Btn_Edit_Click
'When Click On The This Button Then --> (  Label_Clicked_On_LoOp = New Value(Editedt Text Of Edit Text)  )
End Sub




Sub Create_Btn_Edt
    Edt_Edit.Initialize("Edt_Edit")
    Edt_Edit.Gravity = Gravity.CENTER
    Edt_Edit.TextColor = Colors.Black
    Activity.Addview(Edt_Edit,1%x,80%y,74%x,10%y)
   
   
    Btn_Edit.Initialize("Btn_Edit")
    Btn_Edit.Color = Colors.Gray
    Btn_Edit.Text = "OK"
    Btn_Edit.Gravity = Gravity.CENTER
    Activity.AddView(Btn_Edit,76%x,80%y,23%x,10%y)

End Sub
 

Attachments

  • x.zip
    6.2 KB · Views: 185

sorex

Expert
Licensed User
Longtime User
I'm confused with your explanation.

Do you want the tag of the label you clicked on in the edit text after pressing the button?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i´m confused too

Maybe my english is to bad to understand the problem
 
Upvote 0

™AsAs4242

Member
Licensed User
Longtime User
i´m confused too

Maybe my english is to bad to understand the problem
No My English Is Very Bad For Explain : ))


Do you want the tag of the label you clicked on in the edit text after pressing the button?

no
when click on label the tag of Clicked lable Placed on edittext

after -->

i edit the text of edittext then click on button

when clicked button the text of label clicked before - > Is equal to edit text


confused ? : (
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I guess thisis what you want, keep an eye on the <-- that marks new lines

B4X:
Sub Globals
    Dim Element_Top As String
    Dim Edt_Edit As EditText
    Dim Btn_Edit As Button
    Dim lbl_Test As Label
    Dim selected_label As Label   '  <-- to store the selected label
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.Color = Colors.LightGray
Create_Btn_Edt
Element_Top = 2%y


For i = 0 To 7
    lbl_Test.Initialize("lbl_Test")
    lbl_Test.Color = Colors.DarkGray
    lbl_Test.TextColor = Colors.White
    lbl_Test.Gravity = Gravity.CENTER
    lbl_Test.Text = i
    lbl_Test.tag = i
Activity.AddView(lbl_Test,2%x,Element_Top,96%x,7%y)
Element_Top = Element_Top + 9%y
Next

End Sub


Sub lbl_Test_Click
' When Click On label Created With LoOp Then -->     (  The Text OF Edit Text = lbl Created On lOop Text  )
    Dim lbl_Tag As Label
    lbl_Tag = Sender
    Edt_Edit.Text = lbl_Tag.Tag
    selected_label=Sender '   <-- store the selected label
End Sub


Sub Btn_Edit_Click
'When Click On The This Button Then --> (  Label_Clicked_On_LoOp = New Value(Editedt Text Of Edit Text)  )
Dim lbl As Label      ' <--- new label
lbl=selected_label   ' <--- restore selectedlabel
lbl.Text=Edt_Edit.text ' <--- set text
End Sub
 
Upvote 0

™AsAs4242

Member
Licensed User
Longtime User
I guess thisis what you want, keep an eye on the <-- that marks new lines
tnx sorex : )))

but if panel is the parent label ?

i add panel in loop then add label to panel in loop too

when click on panel should text of label at clicked panel be in edit text

and when click on button the new text (edited in edittext) is equal to clicked panel label
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
if you use an array for the panels and labels and use the same index then it should be no problem.

it's just a matter of playing with that selected_label value (which then is selected_panel actually)
 
Upvote 0
Top