Scroll view cannot be emptied

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,
I have a scrollview, where I place panels and buttons.

Sometimes, I have to empty and refill it.

If it contains 5 items, and next time it needs only 3, the last 2 remain visible.

How can I remove all the panels before refilling?

Thank you

Peter

Dim Scrollcats As ScrollView

Scrollcats.Initialize(200)
Activity.AddView(Scrollcats, 250dip, -50dip, 400dip, 300dip)
' Scrollcats.Panel.RemoveAllViews : this has no effect
' Scrollcats.invalidate : this has no effect
' Scrollcats.Panel.Invalidate : this has no effect
For i=0 To nnn
Dim pnlcat As Panel
Dim btncat As Button
pnlcat.Initialize("pnlcat")
Scrollcats.Panel.AddView(pnlcat,0,5dip+i*persPanelHeight, 300dip,persPanelHeight)
pnlcat.Tag=i
pnlcat.Color=Colors.Red
btncat.Initialize("btncat")
pnlcat.AddView(btncat,5dip, 5dip, 170dip, 40dip)
btncat.Tag=...
btncat.Text=...
next
Scrollcats.Panel.Height=(i+2)*persPanelHeight
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Try:

B4X:
For i=Scrollcats.Panel.NumberOfViews-1 to 0 step -1
     Scrollcats.Panel.GetView(i).RemoveView
     Next

I have had this problem as well! You are not alone.

Regards
Mark
 
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
@Mark: Thank you too, but Klaus was right. It seems that when calling the initialize 2 times, 2 views are created one on top of the other.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…