Row Count in a Scrollview

Bill Norris

Active Member
Licensed User
Longtime User
I have 2 scrollviews on the activity. Scrollview1 is populated with labels. When you touch a label on one scrollview1, then scrollview2 populates with items that are related to the label touched on the scrollview1. That all works fine. However, when the user then touches a different label on scrollview1, it populates scrollview2 with a whole new set of labels, on top of the labels generated by the previous touch. I have the panel color set to transparent, so I end up with labels on top of other labels. I realize now that I need to first remove the previous labels before re-populating with new ones. I figured out how to do it, but my solution seems rather convoluted. Is there a simple way to get the total number of rows on a panel. I tried storing the number of rows in a variable, then, before re-populating with the new items:

B4X:
If scrollview2_rowcount>0 then
for i=0 to scrollview2_rowcount-1
scrollview1.panel.removeview(lbl_item(i))
next

but that generates an error on compile because lbl_item() has not been initialized at that point in the code. lbl_item() doesn't get initialized until the database has been read, which determines the number of rows required, as in
B4X:
lbl_item(cursor1.rowcount).initialize("")
 
Top