Android Question How do I get an index from designer?

Levisvv

Member
Licensed User
Longtime User
I created a layout in designer that has several other scrollview layouts on it.
On my activity create I load the layout and a few scrollviews.

B4X:
Activity.LoadLayout("Frame")
    WebPage.LoadLayout("WebLayout")
    menu1.Panel.loadlayout("MainMenu")
    menu2.Panel.loadlayout("SubMenu1")
    menu3.Panel.loadlayout("SubMenu2")

How can I find out the index to one of the scrollviews to remove it during runtime? or can this even be done?
 

Levisvv

Member
Licensed User
Longtime User
to clarify: I need the index of the view of one of the scrollviews (menu1, menu2 or menu3).
I want to use: Activity.RemoveViewAt(x) = where x= the menu1 view index
 
Upvote 0

Levisvv

Member
Licensed User
Longtime User
Activity.GetView can get me the view if I know the index, but I need the opposite of that, I know the view (i.e. menu1) but I need it's index..?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
You can use activity.GetAllViewsRecursive to loop through the views and when you find it by it's tag delete it.

not sure if this works but it should be close...

B4X:
For Each V As View In Activity.GetAllViewsRecursive
 If V.Tag="menu1" Then V.RemoveView
Next
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You show only one SrollView at any time.
Couldnt'you use only one Scrollview ?
When you need to change the content, remove all views from SrollView.Panel and add the new ones.
From my point of view it would be more efficient and minimize the need of memory.
 
Upvote 0

Levisvv

Member
Licensed User
Longtime User
that is exactly what I am trying to accomplish.
Is there any sample code on the best way to do this?
Right now I am loading many scrollviews and just making them visible or not and it is causing lots of memory problems.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is there any sample code on the best way to do this?
Not that I know.
You say you are loading many Scollviews.
This means that you have routines to fill them.
So depending on what you want to display you should remove all views from ScrollView.Panel and add the new ones.
 
Upvote 0

Levisvv

Member
Licensed User
Longtime User
I fixed it, I now only load the scrollview layout when it is needed, otherwise I remove all views from them.
It makes the different scrollviews take about 1/2 a second to load, but a smal price to pay for actually having it work.

thanx
 
Upvote 0
Top