My scrollview has a bunch of labels. Full width of the screen. Labels have varying height depending on the height required to show the text. I want to be able to click on the label and edit the text therein.
I made a click even for the label, but nothing is passed indicating which label is clicked. No position (from the scrollview), not label text. I tried to get these with no success.
Here is my code:
Any ideas on how to use either the position in the scrollview or the name of the label to allow me to edit the label text?
I made a click even for the label, but nothing is passed indicating which label is clicked. No position (from the scrollview), not label text. I tried to get these with no success.
Here is my code:
B4X:
Sub BigSpellView(RowMap As Map, HeaderList As List)
Dim scvText As ScrollView
Dim txt As String
Dim panelheight As Int
Dim labelheight As Int
Dim top As Int
Log("RowMap = " & RowMap)
scvText.Initialize(100dip) ' initialize the Scrollview
pnlTest.AddView(scvText, 0, 0, 100%x, 100%y-40dip) ' add the Scrollview on the Activity
For Each ColumnName In HeaderList
If ColumnName <> "Level All" Then
txt = ColumnName & ": "& RowMap.Get(ColumnName)
If txt <> "" Then
Dim lblText As Label : lblText.Initialize("lblText") ' initialize the Label for the text.
lblText.Color = Colors.RGB(250, 250, 210) 'set the Label background color
lblText.TextColor = Colors.Black ' set the Label text color
lblText.Text = txt ' set the text string to the Label text property
scvText.Panel.AddView(lblText, 0, top ,100%x, 100%y) ' add the Label on the ScrollView internal Panel
labelheight = su.MeasureMultilineTextHeight(lblText, txt) 'measure Label height
panelheight = panelheight + labelheight +5'set the ScrollView internal Panel height to the measured height
lblText.Height = labelheight 'set the Label height to the measured height
top = top + labelheight + 5
End If
End If
Next
Log("panelheight = " & panelheight)
scvText.Panel.Height = panelheight
scvText.ScrollPosition = 0 ' set the scroll position to the top of the text
DoEvents 'needed to execute the previous line
End Sub
Sub lblText_Click
Log("clicked")
End Sub
Any ideas on how to use either the position in the scrollview or the name of the label to allow me to edit the label text?