What does RemoveView(at) Do?

SeaCay

Member
Licensed User
Longtime User
Hello All,

I was wondering what does RemoveView or RemoveViewAt actually do.

The wiki says
"Removes this view from its parent."

I am aware that the nominated view disappears. But it crossed my mind at to whether the views are deleted from memory or can the views be-instantiated?

Further thoughts were if the view was only hidden, and I no longer need the view, do I need to perform any memory management/garbage collection to prevent memory leaks or is there no concern of this nature at all?

Thanks for your help on this question

regards

SeaCay
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi,
Try this code below
Sub RemoveAllViews
Dim I As Int
For I = Activity.NumberOfViews - 1 To 0 Step -1
Activity.RemoveViewAt(I)
Next
End Sub
Best Regards
Theera
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
That's not entirely true. RemoveView removes a View from the ViewGroup of its parent and that is all. The View is only collected by the GC if no further references to it exist. You can keep a reference to a removed View in a variable and add it back to another (or the same) Panel or Activity without having to reinstantiate it.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
You can keep a reference to a removed View in a variable and add it back to another (or the same) Panel or Activity without having to reinstantiate it.

You cant' keep a reference to a View and use the same instance of that View in another Activity i thought?

Aren't Views created with the Context of the Activity that calls their constructor?

Martin.
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I am using an example i got in the forum to implement a grid, adding labels to a scrollview.

I fill the scrollview with rows that are labels. That works fine.

When i need to save my list, i go thru all the labels to create a list to save. I do not keep references to this labels or data in a separated list.

After saving I go over the list to delete it using this code:

'Clears the table
For i = svList.Panel.NumberOfViews -1 To 0 Step -1
svList.Panel.RemoveViewAt(i)
Next

however I found that besides the view disappears (the labels are gone from the scrollview) next time that i recreate the grid list with other items, when is the moment to save again, i go thru the list and i get the current labels, and all past ones.

That means that besides RemoveViewAt remove the label it is being kept on the list and are accessible on the panel list of views.

What is happening? Maybe i am not understanding something else.

Thanks,
 
Last edited:
Upvote 0
Top