Store panel in a map

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello,

I'm wondering the following:
I'm having a panel which have some imageviews attached to it.
If i store the panel in a map, and call it back later, does the attached views gets lost?

When i do some logging after returning the panel, it seems that number of views = 0, but i can still keep the tag and other stuff of the panel.

Note that i'm using a class to store the panel to a map and also restore it from the same class.

Tomas
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
I'm storing and retrieving the panels in the map as following:

B4X:
'Add a new strip
Sub btnAddStrip_Click
   'Declaration of panel to add
   Dim left, top, width, height As Int
   Dim iv As ImageView
   iv.Initialize("ivStrip")
   vw = iv
   iv.Tag = strips
   iv.Color = Colors.White
   iv.Bitmap = LoadBitmap(File.DirAssets, "tempStrip.png")
   iv.Gravity = Gravity.FILL
   strips = strips+1
   left = 10dip
   width = 240
   height = 150
   top = svStrips.Panel.NumberOfViews*(height+imgSpace) + 55dip
   
   'Add the panel to the scrollview
   svStrips.Panel.AddView(iv, left, top, width, height)
   
   'Set scrollview panel
   If svStrips.Panel.NumberOfViews >4 Then
      svStrips.Panel.height = svStrips.Panel.height + (height+imgSpace)
   End If
   
   SelectedStrip = iv.Tag

   'Saves the current canvas to a map.
   mapPanels.Put(iv.Tag, pnlCanvas)
   
   ClearPanelCanvas
End Sub

'Show the options for the strips
Sub ivStrip_Click
   vw = Sender
   ac2.show(vw)
   ClearPanelCanvas
   LoadPanelCanvas(vw.Tag)

End Sub

'Clears the canvas panel
Sub ClearPanelCanvas
   For i = pnlCanvas.NumberOfViews-1 To 0 Step -1
      pnlCanvas.RemoveViewAt(i)
   Next

End Sub

'Loads the panel belonging to the strip
Sub LoadPanelCanvas (index As Int)
   Dim pnl As Panel
   pnl = mapPanels.Get(index)
   pnlCanvas = pnl
End Sub

This keeps me loading a white panel after clicking a strip.

According to thedesolatesoul:


Is this correct, and so how would i solve this?

Tomas
 
Last edited:
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
The Panel inside the Map will not change. Your code looks a bit strange. You are not creating a new panel in btnAddStrip_Click.

I have one big main panel (pnlCanvas) where the user is able to draw one or place an imageview on it.
I got smaller imageviews (called strips) at the right of the pnlCanvas.
When i create a new strip, or I save a strip, it will save the panel with the tag of the strip.

B4X:
'Saves the current canvas to a map.
    mapPanels.Put(iv.Tag, pnlCanvas)

When I click a strip, it will first clear the pnlCanvas and then loads the panel according to the tag of the strip.

B4X:
'Loads the panel belonging to the strip
Sub LoadPanelCanvas (index As Int)
   Dim pnl As Panel
   pnl = mapPanels.Get(index)
   pnlCanvas = pnl
End Sub

http://php.olvgroeninge.be/~sac.26A-07/B4A/IMG_20120724_205019.jpg

This is what i mean with the strips (right) and the pnlCanvas (left)
I hope i made this a little more clearer.

Tomas

Edit:

I've managed to fix it using types, but i'm resulting in a StackOverflowError.
Why does this happen? Do I have too many view? how can i resolve this?
 
Last edited:
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
This is the log:


I don't know when it exactly happening and I cannot seem to find out how to debug it.
It happens a while after i'm adding new strips and importing new bitmaps.
I don't know in which sub it occurs or on what line.

Tomas
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…