Android Question [Solved] How to use ReplaceAt in a CustomListView filled with AddTextItem?

asales

Expert
Licensed User
Longtime User
I have a CLV filled with AddTextItem method.

There are a ReplaceAt method in the component CLV:
ReplaceAt(index AS Int, pnl as B4XView, ItemSize as Int, Value as Object)
but I have only the Index.

Can I replace the text of AddTextItem use the ReplaceAt or only if I use a custom panel?

Thanks in advance for any help.
 
Solution
Can I replace the text of AddTextItem use the ReplaceAt
Yes, you can. I am pretty sure this is it:
B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)    
    Log("Old value: " & Value)
    Dim p As B4XView = CustomListView1.GetPanel(Index)
    Dim x As String ="mynewvalue" & Index
    p.GetView(0).text =x    '1st label in item panel at given index i
    p.RemoveViewFromParent
    CustomListView1.ReplaceAt(Index,p,75dip,x)
End Sub

Mahares

Expert
Licensed User
Longtime User
Can I replace the text of AddTextItem use the ReplaceAt
Yes, you can. I am pretty sure this is it:
B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)    
    Log("Old value: " & Value)
    Dim p As B4XView = CustomListView1.GetPanel(Index)
    Dim x As String ="mynewvalue" & Index
    p.GetView(0).text =x    '1st label in item panel at given index i
    p.RemoveViewFromParent
    CustomListView1.ReplaceAt(Index,p,75dip,x)
End Sub
 
Upvote 1
Solution

Serge Bertet

Active Member
Licensed User
Longtime User
Thanks to @Mahares code but I wanted to use the same color and height as the original CustomListView even if @Erel don't want us to use the GetRawListItem method of CustomListView .
B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)  
    Log("Old value: " & Value)
    Dim p As B4XView = CustomListView1.GetPanel(Index)
    Dim x As String ="mynewvalue" & Index
    p.GetView(0).text =x    '1st label in item panel at given index i
    p.RemoveViewFromParent
    p.color = CustomListView1.GetRawListItem(Index).Panel.Color ' same color
    CustomListView1.ReplaceAt(Index, p, CustomListView1.GetRawListItem(Index).Panel.Height, x) ' same height
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…