Android Question [SOLVED] clv.InsertAt

mmieher

Active Member
Licensed User
Longtime User
I must not understand clv.InsertAt. The code below blows up on the .InsertAt with a "The specified child already has a parent". Can someone please explain how to do this?

B4X:
Sub bUp_Click
    Log("UP")
  
    If clvIndex = 0 Then Return
  
    Dim svValue As Int = clv.GetValue(clvIndex)
    Dim svPanel As Panel = clv.GetPanel(clvIndex)
  
    clv.RemoveAt(clvIndex)
    clvIndex = clvIndex - 1
    clv.InsertAt(clvIndex,svPanel,svValue)
End Sub

Sub bDown_Click
    Log("DOWN")
  
    If clvIndex = clvSize - 1 Then Return
    Dim svValue As Int = clv.GetValue(clvIndex)
    Dim svPanel As Panel = clv.GetPanel(clvIndex)
  
    clv.RemoveAt(clvIndex)
    clvIndex = clvIndex + 1
    clv.InsertAt(clvIndex,svPanel,svValue)
  
End Sub
 
Top