Android Question [B4X] Update value of an item in CustomListView

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, is it possibile to update the value of an item of a custom list view?
because i do not see any method for this, the only way i figured out is to:
  1. save the view using .GetPanel
  2. save the value using .GetValue
  3. update the value
  4. replace the item using .ReplaceAt and using the new value with the view (or RemoveAt and InsertAt)
but i get this errore if a try to do it, on the ReplaceAt/InsertAt
B4X:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

thanks in advance
 
Solution
but i get this errore if a try to do it, on the ReplaceAt/InsertAt
Here it is. If it is of no help, please post some code Mike. Don't be stingy with posting code:
B4X:
Sub CLV1_ItemClick (Index As Int, Value As Object)  'replace a text in a given item panel with another
    Dim p As B4XView = clv1.GetPanel(Index)
    Dim selColor As Int = xui.Color_ARGB(255,144,238,144)
    p.Color = selColor
    Dim x As String ="myxclv" & Index
    p.GetView(0).text = x    '1st label in item panel at given index i
    p.RemoveViewFromParent  
    clv1.ReplaceAt(Index,p, p.Height,x)
End Sub

Mahares

Expert
Licensed User
Longtime User
but i get this errore if a try to do it, on the ReplaceAt/InsertAt
Here it is. If it is of no help, please post some code Mike. Don't be stingy with posting code:
B4X:
Sub CLV1_ItemClick (Index As Int, Value As Object)  'replace a text in a given item panel with another
    Dim p As B4XView = clv1.GetPanel(Index)
    Dim selColor As Int = xui.Color_ARGB(255,144,238,144)
    p.Color = selColor
    Dim x As String ="myxclv" & Index
    p.GetView(0).text = x    '1st label in item panel at given index i
    p.RemoveViewFromParent  
    clv1.ReplaceAt(Index,p, p.Height,x)
End Sub
 
Upvote 1
Solution

Mike1970

Well-Known Member
Licensed User
Longtime User
Here it is. If it is of no help, please post some code Mike. Don't be stingy with posting code:
B4X:
Sub CLV1_ItemClick (Index As Int, Value As Object)  'replace a text in a given item panel with another
    Dim p As B4XView = clv1.GetPanel(Index)
    Dim selColor As Int = xui.Color_ARGB(255,144,238,144)
    p.Color = selColor
    Dim x As String ="myxclv" & Index
    p.GetView(0).text = x    '1st label in item panel at given index i
    p.RemoveViewFromParent 
    clv1.ReplaceAt(Index,p, p.Height,x)
End Sub
thank you it worked
 
Upvote 0
Top