ScrollView performance

eps

Expert
Licensed User
Longtime User
Okay..

So I've got a Database with circa 1000 records. Initially I was filling a ListView with these and displaying them.

All was well, the display was almost instantaneous, on a Desire HD.

I then wanted to grey out entries that were in the past.. ListView doesn't allow you to have different colours for items in a list. So I looked at ScrollView. Now this seems to be a lot slower (4 seconds, might not sound a lot but it seems like a long time in an App) in population than ListView. Admittedly it's doing a little more processing to grey items out, but is it just accepted that ScrollView is a lot slower than ListView? I have put some metrics in place and attempted to improve things, but can only seem to get so far.. Any thoughts? Happy to post the code, later on, when I've got it to hand. Maybe I've dropped a clanger in the code somewhere, but I don't think I have.. The SQL access is quick - the population of the ListView or a List is mega quick, it's definitely the ScrollView stuff that seems to be taking the time. I have got some further possibilities to try, but wondered if anyone else had come across this?

I was tempted by having a ListView and then having a different bitmap alongside the (two line) entries to indicate those in the past as opposed to those still current or in the future..

mtia!
 

eps

Expert
Licensed User
Longtime User
Erel, just two lines of text, please tell me more about setting the bitmap visible to false and giving the items a different colour! This sounds very intriguing..
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Okay...!!

So now I've got the attached, which is from this

B4X:
        'store todays date for later use in FOR loop
   Dim v_today_date_ticks As Long
   v_today_date = DateTime.Date(DateTime.Now)
   v_today_date_ticks = DateTime.DateParse(v_today_date)   
   
   
   'populate the listview of ALL the races in date order
   ListView1.TwoLinesLayout.Label.TextSize = 10dip
   ListView1.TwoLinesLayout.SecondLabel.TextSize = 10dip
   ListView1.TwoLinesLayout.Label.Gravity = Gravity.LEFT
   ListView1.TwoLinesLayout.SecondLabel.Gravity = Gravity.FILL
   ListView1.TwoLinesLayout.SecondLabel.Top = 19dip
   ListView1.TwoLinesLayout.Label.Height = 19dip
   ListView1.TwoLinesLayout.SecondLabel.Height = 19dip
   ListView1.ScrollingBackgroundColor = Colors.Transparent
   ListView1.TwoLinesLayout.ItemHeight = 40dip
   'ListView1.TwoLinesLayout.ItemHeight = canvas1.height/8
   

       'set up items for display in TwoLinesAndBitmap part of the ListView
   ListView1.TwoLinesAndBitmap.ImageView.Visible = False
   'ListView1.TwoLinesAndBitmap.ImageView.Width = 0
   ListView1.TwoLinesAndBitmap.ImageView.RemoveView
   Dim cd As ColorDrawable
   cd.Initialize(Colors.Transparent, 0)
   ListView1.TwoLinesAndBitmap.Background = cd
   ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Gray
   ListView1.TwoLinesAndBitmap.Label.TextSize = 10dip
   ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10dip
   ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.LEFT
   ListView1.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.FILL
   ListView1.TwoLinesAndBitmap.SecondLabel.Top = 19dip
   ListView1.TwoLinesAndBitmap.Label.Height = 19dip
   ListView1.TwoLinesAndBitmap.SecondLabel.Height = 19dip
   'ListView1.ScrollingBackgroundColor = Colors.Transparent
   ListView1.TwoLinesAndBitmap.ItemHeight = 40dip

   
   
   
   ListView4.Initialize("ListView4")
   Cursor = SQL1.ExecQuery("SELECT _id, name, startdate, display_date FROM event order by date(startdate)")
   Log(Cursor.RowCount)
   For i=0 To Cursor.RowCount-1
      Cursor.Position=i
      'ListView1.AddSingleLine(Cursor.GetString("Name"))
      
      If DateTime.DateParse(Cursor.GetString("startdate")) < v_today_date_ticks Then   
   
         ListView1.AddTwoLinesAndBitmap2(Cursor.GetString("name"), Cursor.GetString("display_date"), Null, Cursor.GetInt("_id"))
      'ListTemp.Add(CursorTemp.GetInt("_id"))
      Else
      
      'ListViewTemp.Visible = True
      
         ListView1.AddTwoLines2(Cursor.GetString("name"), Cursor.GetString("display_date"), Cursor.GetInt("_id"))
      'ListTemp.Add(CursorTemp.GetInt("_id"))
      End If
      
      'ListView1.AddTwoLines(Cursor.GetString("name"),Cursor.GetString("display_date"))
      ListView4.AddSingleLine(Cursor.GetInt("_id"))
   Next
   Cursor.Close

I've tried a number of ways (see above) to remove the indentation, presumably from usually having a bitmap in there, but of course I haven't. Is it possible to remove/squash this down to nothing or a lot less?

P.S. Don't worry about ListView4, this was being used to store the id from the table in question, but then I started to use AddTwoLines2 to display two items and store a hidden idkey :) This code is a little old, being used to check using ListView like this, before being used to hopefully replace the ScrollListView code :)
 

Attachments

  • msc_screen_shot.jpg
    msc_screen_shot.jpg
    11.4 KB · Views: 556
Upvote 0

eps

Expert
Licensed User
Longtime User
Klaus

Vielen dank!

That seems like it should work. I will try those tonight. I had tried width, but it didn't work, but maybe a combination of all 3...


Will report back later, but optimistic.

:)
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Klaus, Erel a combined genius team!!

It now works, with the two set to left, but without width being set to 0.


:)

Many, many, many thanks! This is an amazing boon for my Apps as the performance of ScrollViewList was starting to concern me and also the sizing of it as well! :) Off to rip all my current code apart now....
 
Upvote 0
Top