This is an API demo for dealing with data that is slow to load:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List13.html

You'll of course want to do this a little differently, filling in as much of
each item as you can when binding, and having a background thread loading
images to populate later when they are ready.  (Instead of the stuff this
demo does with the scroll state changing.)

On Fri, Aug 27, 2010 at 2:59 PM, ls02 <agal...@audible.com> wrote:

> I did some profiling and it turned out significant time is spent on
> loading images. Each listview item has a distinctive image. i have
> thousands of items in my listview so I cannot cache them. I tried to
> create an image on card folder cache of either PNG or JPEG image files
> of exactly the same dimension as the images I render in listview item
> ImageView. It helped but still not ideal.
>
> I thought about saving uncompressed bitmap data to a an image cache
> file with hope it will be faster to load and render since the image
> won't need to be decompressed. But i didn't find any class or method
> to save and load uncompressed bitmaps. The only way I see to save the
> image to a disk file is Bitmap.compress which can be either JPEG or
> PNG (BTW, which one from these two is faster to load and render?).
>
> I also thought about loading images in worker thread but this appears
> to be very complicated and I am not sure it will help and won't create
> other problems. I would have to create a queue if currently visible
> items and have to load images inside that thread. I worry that while I
> load a title image it is already scrolled out and becomes invisible.
>
>
> On Aug 26, 11:26 pm, Dianne Hackborn <hack...@android.com> wrote:
> > http://developer.android.com/guide/developing/tools/traceview.html
> >
> > <http://developer.android.com/guide/developing/tools/traceview.html>This
> may
> > not be documented, but in newer versions you can use the "am" command to
> > start and stop profiling.  Use "adb shell am" to get help for the
> command.
> >
> >
> >
> >
> >
> > On Thu, Aug 26, 2010 at 7:59 PM, ls02 <agal...@audible.com> wrote:
> > > How do I profile the code? I do recycle bitmaps since each list item
> > > displays its own bitmap image and without recycling I quickly run out
> > > of memory.
> >
> > > On Aug 26, 10:50 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > > Run your code in a profiler.
> >
> > > > Make sure you aren't thrashing through temporary objects.  If the GC
> is
> > > > running much while scrolling, optimize to reduce temp objects.
> >
> > > > On Thu, Aug 26, 2010 at 6:18 PM, ls02 <agal...@audible.com> wrote:
> > > > > I have list view with fairly complex list view items consisting of
> > > > > several image views, several text views, progress bars, etc.
> Depending
> > > > > on the state of the item some of these elements can be show and
> some
> > > > > are hidden. I understand that listview recycles views. Right now I
> am
> > > > > dealing with slow listview scrolling especially on lower powered
> > > > > devices. What's the best way to deal with this problem?
> >
> > > > > I already optimized each list item view as much as I could. Now I
> am
> > > > > facing with what's the best? Use one single view with many children
> > > > > for all items and hide and show various children depending on the
> item
> > > > > state. This way I do not inflate each item view as list is being
> > > > > scrolled but need to show and hide constantly various child views.
> >
> > > > > Another approach is to build item view dynamically each time view
> is
> > > > > requested in the adapter getView method. In this case I can only
> add
> > > > > at run time those elements that are truly needed for current item
> > > > > state but this requires inflating item view every time.
> >
> > > > > Finally  the third approach is most extreme is to have one custom
> view
> > > > > and draw everything myself. This of cause requires a lot of work.
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to
> > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> <android-developers%2bunsubs­cr...@googlegroups.com>
> > > <android-developers%2bunsubs­cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
> >
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > hack...@android.com
> >
> > > > Note: please don't send private questions to me, as I don't have time
> to
> > > > provide private support, and so won't reply to such e-mails.  All
> such
> > > > questions should be posted on public forums, where I and others can
> see
> > > and
> > > > answer them.- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> <android-developers%2bunsubs­cr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
> >
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see
> and
> > answer them.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to