Android Question xCustomListView & CLVExpandable

Johan Schoeman

Expert
Licensed User
Longtime User
I have an Imageview inside and Expandable Listview:

This line of code gets the applicable panel in the ListView

B4X:
Dim pnlItems As B4XView = clv1.GetPanel(index).GetView(1)

This line of code gets the ImageView in the expandable listview

B4X:
pnlItems.GetView(0).SetBitmap(lastPicture)

How can I force a redraw (Invalidate) of the bitmap loaded into the Imageview? There seems to be no Invalidate method to force a redraw?

1602868049977.png


Thanks

JS
 

LucaMs

Expert
Licensed User
Longtime User
Dim pnlItems As B4XView = clv1.GetPanel(index).GetView(1)
This should return your ImageView, I think, not the item panel.

Try:
B4X:
Private Sub clv1_ItemClick (Index As Int, Value As Object)
    Dim iv As B4XView = clv1.GetPanel(Index).GetView(1)
    iv.SetBitmap(lastPicture)
End Sub

EDIT: you're talking about Expandable CLV; sorry, I tried a simple xCLV. Is it the same? Currently don't know :)
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Struggling but I did it.

B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
    expandable.ToggleItem(Index)
    Sleep(clv1.AnimationDuration + 20) ' <---
    Dim pnl As B4XView = clv1.GetPanel(Index).GetView(1)
    dim iv as B4XView = pnl.GetView(0)
    iv.SetBitmap(lastPicture)
End Sub

I have used and modified Erel's example (attached).
 

Attachments

  • B4A_ExpandableList_Changed.zip
    14.8 KB · Views: 144
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Struggling but I did it.

B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
    expandable.ToggleItem(Index)
    Sleep(clv1.AnimationDuration + 20) ' <---
    Dim pnl As B4XView = clv1.GetPanel(Index).GetView(1)
    dim iv as B4XView = pnl.GetView(0)
    iv.SetBitmap(lastPicture)
End Sub

I have used and modified Erel's example (attached).
My code above does set the Bitmap but I need to then do a redraw and there is not a Invalidate method to do so......
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
In this case declare the view as ImageView .. not B4XView

B4X:
Dim pnl As B4XView = clv1.GetPanel(Index).GetView(1)
dim iv as ImageView = pnl.GetView(0)
iv.Bitmap = LastPicture
iv.Invalidate ...




As a side note ... If you declare the panel as B4XView , you can reference the child b4xView's properties without explicitly declaring them ie: (Refer post #3)
B4X:
Dim pnl As B4XView = clv1.GetPanel(Index).GetView(1)
pnl.GetView(0).SetBitmap(lastPicture)
 
Last edited:
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
In this case declare the view as ImageView .. not B4XView

B4X:
Dim pnl As B4XView = clv1.GetPanel(Index).GetView(1)
dim iv as ImageView = pnl.GetView(0)
iv.Bitmap = LastPicture
iv.Invalidate ...

It does not invalidate (redraw) the bitmap in the ImageView that is located at pnl.GetView(0). When I close the app and then open the app again the image displays correctly. But without closing the app the bitmap does not fit the ImageView.
 
Upvote 0
Top