Android Question Remove all outline view

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hi to all, can anyone helps me with this simple sub? I don't have any idea why it doesn't work. I've a panel. Each 3 seconds i create a panel inside it, at bottom of previously panel. I wrote a small sub that delete all outline panels. But i don't understand why, it give me an error.

This is the sub that i use to remove panel:
B4X:
Private Sub RemoveOutlineView
   
    Log(pnlTwView.NumberOfViews & " view")   
    For Each p As Panel In pnlTwView
        If (p.Top+p.Height) > pnlTwView.Height Or p.Top < (0 - p.Height) Or p.Left < (0 - p.Width) Or p.Left > pnlTwView.width Then
            p.RemoveView
        Else
            Log(p.Top & "_ "&p.Top)
        End If
    Next
End Sub

And this is the error:
B4X:
Transizione partita: 1
Panel size is unknown. Layout may not be loaded correctly.
1 view
0_ 0
Sono entrato in timan
Da tim animation 4800
Transizione partita: 2
Panel size is unknown. Layout may not be loaded correctly.
2 view
183_ 183
0_ 0
Sono entrato in timan
Da tim animation 4800
Transizione partita: 3
Panel size is unknown. Layout may not be loaded correctly.
3 view
366_ 366
183_ 183
0_ 0
Sono entrato in timan
Da tim animation 4800
Transizione partita: 4
Panel size is unknown. Layout may not be loaded correctly.
4 view
549_ 549
366_ 366
183_ 183
0_ 0
Sono entrato in timan
Da tim animation 4800
Transizione partita: 5
Panel size is unknown. Layout may not be loaded correctly.
5 view
366_ 366
183_ 183
0_ 0
twitterviewer_removeoutlineview (B4A line: 619)
Log(p.Top & "_ "&p.Top)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.PanelWrapper.Get(PanelWrapper.java:142)
    at integralab.twitter.com.twitterviewer._removeoutlineview(twitterviewer.java:1180)
    at integralab.twitter.com.twitterviewer._trans_eventcomplete(twitterviewer.java:1503)
    at integralab.twitter.com.twitterviewer._timcontrolanimation_tick(twitterviewer.java:1480)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5646)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:744)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
 

Emme Developer

Well-Known Member
Licensed User
Longtime User
I finally got the issue. In the for loop, after removing the view, change the value of pnltwview, so i got an error when i try to see log of last view.
Finally is my code:

B4X:
For i = pnlTwView.NumberOfViews-1 To 0 Step-1
Dim p As Panel = pnlTwView.GetView(i)
    If p.Top+3 > pnlTwView.Height Or p.Top < (0 - p.Height) Or p.Left < (0 - p.Width) Or p.Left > pnlTwView.width Then
   p.RemoveView
   End If
Next
 
Last edited:
Upvote 0
Top