Android Question RemoveView Suddenly Not Working

mmieher

Active Member
Licensed User
Longtime User
Have I gone crazy? All of a sudden, RemoveView does not seem to be working. Attached is a simple Project.

This will probably end up being embarrassing.
 

Attachments

  • Test.zip
    9.7 KB · Views: 90

klaus

Expert
Licensed User
Longtime User
It works !
What exactly do you want to achieve and what exactly do you expect ?
You add a transparent Panel on Activity.
Then you load a layout with a Label on Activity.
When you press on the Label the Panel disappears, but you see nothing.
I added two lines to display the number of views on Activity:
B4X:
Private Sub Label1_Click
    Log("REMOVE VIEW")
    Log(Activity.NumberOfViews)
    SpinnerPage.RemoveView
'    SpinnerPage.Visible = False    '    This does not work either
    Log(Activity.NumberOfViews)
End Sub
The first shows 2, the Panel and the Label.
And the second shows 1, the remaining Label.
If you set a color for your Panel you will see that it disappears.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Thanks for your usual quick reply, Klaus.

I must have messed something up in my setup of B4A. This does not work here.

I did add the Activity.NumberOfViews to the click event. The number does descend.

However, my panels are not transparent. Layout is Green. Spinner is Red. Label is in Layout.

When I AddView Spinner, the panel is red, but I still see the label in Layout. Neither should be true. Right?

When I SpinnerPage.RemoveView, the screen is still red. I would expect it to be green.

Log:

** Activity (main) Create, isFirst = true **
Activity_Create
** Activity (main) Resume **
REMOVE VIEW
Before 2
After 1


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    
    Private SpinnerPage As Panel
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    Log("Activity_Create")
    
    Activity.LoadLayout("Layout")
    
    Sleep(3000)    '    So I Can See the Green Background
    TestSpinner
    
End Sub

Private Sub TestSpinner
    
    SpinnerPage.Initialize("SpinnerPage")
    Activity.AddView(SpinnerPage,0,0,100%x,100%y)
    Activity.LoadLayout("Spinner")
    
End Sub

Private Sub Label1_Click
    Log("REMOVE VIEW")
    Log("Before " & Activity.NumberOfViews)
    SpinnerPage.RemoveView
    Log("After " & Activity.NumberOfViews)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
[\CODE]
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
1. You load layout, an empty layout with a green background color.
2. You add SpinnerPage a transparent Panel, a Panel added by code is transparent by default.
3. You load layout Spinner on the Activity, with a red background therefore the green background is 'overwritten' and the Label.
4. You remove the transparent Panel, nothing changes on the screen.

Try the following:
Instead of loading the Spinner layout onto Activity, load it onto SpinnerPage.
Then, when you click the red layout with the Label disappears and the green background is displayed.
 
Upvote 0
Top