Problem with parent/child view

bazp

Member
Licensed User
Longtime User
I have a screen with 3 buttons. When I click on the button I display another button (game), Sometimes it works and sometimes it gives the following error: The specified child already has a parent. You must call REMOVIEW on the parent first. I already do this. Any solution? here is the section of code with the problem.
'------------------------------------------
B4X:
Sub ButtonPress_Click
 Dim b As ImageView
 b = Sender
 b.Enabled=True

 Panel1.GetView(b.tag)
 
 Panel1.RemoveViewAt(b.tag)
   
 b.Bitmap = LoadBitmap(File.DirAssets, MATRIX(b.tag) & ".png")
 panel1.AddView(b, offx(b.Tag), offy(b.Tag), 53 * lv.Scale, 53 * lv.Scale)
 panel1.Invalidate

 End Sub
 

Attachments

  • sample.jpg
    sample.jpg
    9.3 KB · Views: 320
Last edited by a moderator:
Top