Android Question Scrollview Out of memory

alienhunter

Active Member
Licensed User
Longtime User
Hi ,
i just run the first time in the Problem where the scrollview throws a out of memory exception
there could be 500 items sometimes or more .
There are also bitmaps that i load with Bitmap sample

Question how do i reset the scrollview before i loop again , this will load again with a timer every 1 min


thanks AH

B4X:
Sub mainncpanetd

Dim cursor1 As Cursor
Dim lstTable As List


Dim Panel0 As Panel
Dim PanelTop, PanelHeight, Label2Top As Int
Dim label100  As Label
ncqd.Color=Colors.Black
PanelTop=2
Panel0=ncqd.Panel
Panel0.Color=Colors.White
Dim ss ,sc As Int
ss=0
sc=2


sqlw.Initialize(File.DirDefaultExternal,"joblist1.db",False)

cursor1 = sqlw.ExecQuery("SELECT col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11 FROM Table4")



For i = 0 To cursor1.RowCount-1


cursor1.Position=i
   
   
      Dim panel1 As Panel
      panel1.Initialize("View1")
      panel1.Tag=i&"0"
      PanelHeight=60dip *sc
      Label2Top=2dip
      Panel0.AddView(panel1,0,PanelTop,ncqd.Width,PanelHeight)
      panel1.Color=Colors.DarkGray'RGB(Rnd(0,150),Rnd(0,150),Rnd(0,150))
      panel1.Tag=i
       
   
       
        Dim pbbb As ProgressButton
        pbbb.Initialize
        panel1.AddView(pbbb,1dip,70dip,46dip,46dip)
        pbbb.InnerSize=45
    '    pbbb.Progress=Floor(timeleft)
       
       
       
        Dim timerx As Label
        timerx.Initialize("View1")
        panel1.AddView(timerx,46,90,150,30dip)
        timerx.Text="Time Left : " & pbbb.Progress & ".min"
        timerx.Color=Colors.Black
        timerx.TextSize=11dip
        timerx.TextColor=Colors.White
        timerx.Gravity=Gravity.CENTER
       
        Dim stattp As ImageView
        stattp.Initialize("VIEW1")
        panel1.AddView(stattp,(timerx.Left+timerx.Width)+1,74,46,46dip)
        'stattp.Bitmap=LoadBitmap(File.DirAssets,"hot1.jpg")
        'stattp.Bitmap=LoadBitmap(File.DirAssets,"error.png")
        'stattp.Bitmap=LoadBitmap(File.DirAssets,"standby.png")
        stattp.Bitmap=LoadBitmapSample(File.DirAssets,"ok.png",64,64)
        'stattp.Bitmap=LoadBitmap(File.DirAssets,"standbyg.png")
        stattp.Gravity=Gravity.FILL
       

       
       
        Dim jobn As Label
        jobn.Initialize("View1")
        panel1.AddView(jobn,0,0,ncqq.Width,30dip)
        jobn.Text="Job Name : " & cursor1.GetString("col2") & " Part :" & cursor1.GetString("col3")  & " Setup :" &  cursor1.GetString("col4")
        jobn.Color=Colors.Black
        jobn.TextSize=18dip
        jobn.TextColor=Colors.White
        jobn.Gravity=Gravity.CENTER
       
        Dim jobn As Label
        jobn.Initialize("View1")
        panel1.AddView(jobn,0,31,ncqq.Width,30dip)
        jobn.Text= "Machine :" &  cursor1.GetString("col5")& " Nc Name : " &  cursor1.GetString("col6")
        jobn.Color=Colors.Black
        jobn.TextSize=12dip
        jobn.TextColor=Colors.Yellow
        jobn.Gravity=Gravity.CENTER
       
        PanelTop=PanelTop+PanelHeight+5dip
        Panel0.Height=PanelTop
Next
ncqd.Invalidate
End Sub
 

eps

Expert
Licensed User
Longtime User
I think you need to look at other Lists, which don't actually hold all of the elements in memory at once. ULV, Ultimate ListView does this as does CLV, Custom ListView. At least I think the latter one does..

HTH
 
Upvote 0

alienhunter

Active Member
Licensed User
Longtime User
I think you need to look at other Lists, which don't actually hold all of the elements in memory at once. ULV, Ultimate ListView does this as does CLV, Custom ListView. At least I think the latter one does..

HTH

thanks i will try the Custom Listview and see if it works
with the cache lib / strickt mode this is now possible to see your usage
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I think you need to look at other Lists, which don't actually hold all of the elements in memory at once. ULV, Ultimate ListView does this as does CLV, Custom ListView. At least I think the latter one does..
No, the CustomListView has the same limitation. All data have to be in memory.
Only the UltimateListView and, to a lesser extent, the TableView class (and its variant Flexible Table) may save memory by recycling the views to display.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
No, the CustomListView has the same limitation. All data have to be in memory.
Only the UltimateListView and, to a lesser extent, the TableView class (and its variant Flexible Table) may save memory by recycling the views to display.
Cheers I knew ULV was okay and one other, but not which one.
 
Upvote 0
Top