I use ListView with SingleLine items, and I want modify text for selected item
Problem - item contains old value of text, but by another long click I see, what InputDialog gets the text with new value from item... How I can update item text?
B4X:
Type ListViewData (Text As String) ' "dimed" in Sub Globals
Sub lvNames_ItemLongClick (Position As Int, Value As Object)
Dim TD As InputDialog
Dim lvd As ListViewData
lvd = Value
TD.Input = lvd.Text
If TD.Show("Edit text", "", "OK", "Cancel", "", Null) = DialogResponse.POSITIVE Then
lvd.Text = TD.Input
lvNames.Invalidate
End If
End Sub
Since I don't see a setItem method, probably you should reconstruct the listView after your changes. For example, you can have all items stored in a list (not listview) and then repopulate your listview with it, after a clear. If not having a very large list, you could also try using a scrollview, which would make replacements more straight forward.
Updates SelectedItems scrollView - which is NOT a listView
B4X:
Sub btnModif_Click
Dim row(NumberOfColumns) As String
row(0)=edtCode.Text
row(1)=edtFirstName.Text
row(2)=edtLastName.Text
SQL1.ExecNonQuery("UPDATE table1 Set Code = '"&row(0)&"', First = '"&row(1)&"', Name = '"&row(2)&"' WHERE Code = '" & GetView(SelectedItems.Get(0),0).Text & "'")
For i=0 To NumberOfColumns-1
SetCell(SelectedItems.Get(0),i,row(i))
Next
End Sub