B4J Question CustomListView1 - lettura contenuto TextField1

MARCO C.

Active Member
Licensed User
Buonasera,
in riferimento ad un progetto esempio sul CustomListView1 che ho recuperato in un post, vorrei sapere come prendere i valori
inseriti nei vari campi TextField1, per esempio, tramite un ciclo FOR , in un vettore o list
valore(1) = "Text 10"
valore(2) = "Text 20"
valore(3) = "Text 30"
valore(4) = "Text 4"
.
.

custom.png


Grazie in anticipo
M.

Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI

Private CustomListView1 As CustomListView
Private CheckBox1 As CheckBox
Private Label1 As Label
Private Button1 As Button
Private lblValore As Label
Private lblTestoLabel As Label
Private TextField1 As TextField
End Sub

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("layMain") 'Load the layout file.
MainForm.Show
RiempiXCLV
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub


Sub RiempiXCLV
For i = 1 To 20
CustomListView1.Add(CreaItem(i), i * 10)
Next
End Sub

Sub CreaItem(Indice As Int) As B4XView
Dim pnlNew As B4XView
pnlNew = xui.CreatePanel("")
pnlNew.SetLayoutAnimated(0, 0, 0, CustomListView1.AsView.Width, 45dip)
pnlNew.LoadLayout("layXCLVItem")
Label1.Text = "Elemento #: " & Indice
If Rnd(0, 2) = 1 Then
CheckBox1.Checked = True
Else
CheckBox1.Checked = False
End If
Button1.Text = "Button " & Indice
TextField1.Text = "Text " & Indice
Return pnlNew
End Sub

Sub Label1_MouseClicked (EventData As MouseEvent)
Dim lbl As Label = Sender
lbl.TextColor = fx.Colors.Red
lblTestoLabel.Text = "Testo: " & lbl.Text

' Si può ottenere il valore associato all'item
' in questo modo:
Dim Indice As Int = CustomListView1.GetItemFromView(lbl) ' va bene anche Sender
Dim Valore As Int = CustomListView1.GetValue(Indice)
Log("Valore: " & Valore)
End Sub

Sub Button1_Click
Dim btn As Button = Sender
btn.TextColor = fx.Colors.Blue
lblValore.Text = "Button: " & btn.Text
End Sub

Sub CustomListView1_ItemClick (Index As Int, Value As Object)
lblValore.Text = "Valore item: " & Value
End Sub
 
Top