Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I actually went through your code and hacked a bit to make it work on my devices. I can confirm your ListAdapter is just fine, and that the problem is elsewhere.</p> <p>This is what you do in the createDefaultLabelsList() method.</p> <pre><code>mItemsInList.clear(); ItemInRootList item; do { item = new ItemInRootList(); item.isLabel = true; item.id = c.getString(c.getColumnIndex(Labels.KEY_ID)); item.title = Labels.label(item.id); //TODO: fix this label.label = c.getString(c.getColumnIndex(Labels.KEY_LABEL)); item.unreadCount = c.getString(c.getColumnIndex(Labels.KEY_UNREAD_COUNT)); mItemsInList.add(item); } while (c.moveToNext()); </code></pre> <p>It seems that not using a local variable in your loop is the cause to your performance problem, believe it or not. Replace that with:</p> <pre><code>mItemsInList.clear(); do { ItemInRootList item = new ItemInRootList(); item.isLabel = true; item.id = c.getString(c.getColumnIndex(Labels.KEY_ID)); item.title = Labels.label(item.id); //TODO: fix this label.label = c.getString(c.getColumnIndex(Labels.KEY_LABEL)); item.unreadCount = c.getString(c.getColumnIndex(Labels.KEY_UNREAD_COUNT)); mItemsInList.add(item); } while (c.moveToNext()); </code></pre> <p>and enjoy your blazing fast list! This solved it for me on htc hero (2.1) and Xoom (3.1) using a ListActivity.</p> <p>That's how I would have done it in the first place - but I'm not exactly sure how this explains the sluggish behaviour with your original implementation.</p> <p>I found this out because in order to reproduce your issue I had to replace the way you built the list, just created a list of with 10k random labels and watched it scroll really fast. I then noticed we didn't use the exact same loop, you were adding the same reference over and over again while I was adding 10k different references. I switched to your implementation and reproduced the bug.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload