B4J Question [SOLVED] View Creation and Remove.... as always can't understand it / why?

Magma

Expert
Licensed User
Longtime User
Well trying to figure where am I wrong...

because I know that I am !!!

1) Well I want to add over the controls in a b4xpage/form new b4xview panels (seems ok)

B4X:
...
    For k=0 To B4XTable1.Columns.Size-1
        headerpanel.As(B4XView)=xui.CreatePanel("headerpanel")
        headerpanel.Tag= "headerpanel" & k

        headerpanel.SetColorAndBorder(xui.Color_Transparent,2,0,0)
    
        Dim cc As B4XTableColumn=B4XTable1.Columns.Get(k)

        leftest=leftest+cc.Width
        
        Root.AddView(headerpanel,leftest,B4XTable1.mBase.Top+41,2,B4XTable1.mBase.Height-60) '+41 for label,search, -60 scrollbar height - can we get those somehow... ?

    Next
...

2) And after a while, i want to remove only them... simple... ??? seems something wrong to me... i remove other b4xviews too... why ?????

B4X:
...
    If headerpanel.IsInitialized And B4XTable1.IsInitialized Then
        For Each v As B4XView In Root.GetAllViewsRecursive'not so right...
                Dim t As String=v.Tag
                If t.Contains("headerpanel") Then  'hmmm no ? but where are those.... ???
                    Log("hey")
                    v.As(Pane).RemoveNodeFromParent
                End If
            Next
    End If
    Sleep(0)
...

Full example here...

(You can see the video too..)
I am adding panels with color Transparent (making Green when move over the mouse)
- after somes secs... for example: searchfield... dissapearing !!! i wanted to remove only the panels added...

 
Solution
Your question has nothing to do with B4XView. B4XView is simply a cross platform API. It doesn't provide any special behavior.

B4X:
Dim ViewsThatShouldBeRemoved As List
ViewsThatShouldBeRemoved.Initialize
 For k=0 To B4XTable1.Columns.Size-1
        Dim headerpanel As B4XView =xui.CreatePanel("headerpanel")
        ViewsThatShouldBeRemoved.Add(headerpanel)
Next

....

For Each v As B4XView In ViewsThatShouldBeRemoved 
 v.RemoveFromParent
Next

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your question has nothing to do with B4XView. B4XView is simply a cross platform API. It doesn't provide any special behavior.

B4X:
Dim ViewsThatShouldBeRemoved As List
ViewsThatShouldBeRemoved.Initialize
 For k=0 To B4XTable1.Columns.Size-1
        Dim headerpanel As B4XView =xui.CreatePanel("headerpanel")
        ViewsThatShouldBeRemoved.Add(headerpanel)
Next

....

For Each v As B4XView In ViewsThatShouldBeRemoved 
 v.RemoveFromParent
Next
 
Upvote 1
Solution

Magma

Expert
Licensed User
Longtime User
Your question has nothing to do with B4XView. B4XView is simply a cross platform API. It doesn't provide any special behavior.

B4X:
Dim ViewsThatShouldBeRemoved As List
ViewsThatShouldBeRemoved.Initialize
 For k=0 To B4XTable1.Columns.Size-1
        Dim headerpanel As B4XView =xui.CreatePanel("headerpanel")
        ViewsThatShouldBeRemoved.Add(headerpanel)
Next

....

For Each v As B4XView In ViewsThatShouldBeRemoved
 v.RemoveFromParent
Next
you mean...
B4X:
v.RemoveViewFromParent

Hey you are a genious... adding them in list (no need to check tag... nothing)... and then just remove !
 
Upvote 0
Top