Using an image in a listview

by Patrick Plaatje » Wed, 06 Jan 2010 23:18:36 GMT

Sponsored Links
 Hi all,

for my app i'm using a listview to display rss news articles. All goes
well, and the implementation is almost done. But when using my app,
i'm not really satisfied with the "smoothness" and user experience of
it. The main problem is that when i scroll through the listview, which
contains an image for each row in the listview, the scrolling isn;t
smooth, it executes the getview override every time. I already threw
out the "holder startegy", as it slowed the scrolling...

any thoughts?



Using an image in a listview

by Brion Emde » Thu, 07 Jan 2010 00:22:52 GMT

 Are you using any of the techniques shown in the example
in the APIDemos? I have a video example of what can be achieved with
such techniques, here: 

> Patrick

Sponsored Links

Using an image in a listview

by Patrick Plaatje » Thu, 07 Jan 2010 00:28:59 GMT

 Hi Brion,

thanks, i will certainly give that a try. But the funy thing is that
i'm actually not attaching that much data to my listview rows. I even
stripped the images from it and i still have some "hickups" when
scrolling. And it's indeed probably the getview method which tries to
attach the data to the view.

But as said i'll give the example a go and see if that helps. Many
thanx in advance.


2010/1/6 Brion Emde <>:


Using an image in a listview

by Vince » Thu, 07 Jan 2010 03:52:17 GMT

 What does your getView code look like. Are re-inflating your row view
every time it's called, are there multiple views for the rows etc?


> Patrick

Using an image in a listview

by Patrick Plaatje » Thu, 07 Jan 2010 03:58:04 GMT


i've used the holder method, but adding or omitting this didn;t give
me an increase or decrease in performance, my getView method is below:

public View getView(int position, View convertView, ViewGroup parent) {

// A ViewHolder keeps references to children views to avoid
unneccessary calls
// to findViewById() on each row.
ViewHolder holder;

holder = new ViewHolder();

// When convertView is not null, we can reuse it directly,
there is no need
// to reinflate it. We only inflate a new View when the
convertView supplied
// by ListView is null.
if (convertView == null){
convertView = mInflater.inflate(R.layout.article_row,

// Creates a ViewHolder and store references to the two
children views
// we want to bind data to.
holder.titleText = (TextView)
holder.descriptionText = (TextView)
holder.icon = (ImageView)

} else {
// get holder back...much faster than inflate
holder = (ViewHolder) convertView.getTag();

// Bind the data efficiently with the holder.



Drawable d = null;
FeedMessage fm = (FeedMessage) Items.get(position);

if(fm.getEnclosures().size() > 0){
String urlString = fm.getEnclosures().get(0);
dm.fetchDrawableOnThread(urlString, holder.icon);
} else {
d =
if(fm.getGuid() != null){

return convertView;

static class ViewHolder {
TextView descriptionText;
TextView titleText;
ImageView icon;



2010/1/6 Vince <>:

Using an image in a listview

by Brion Emde » Thu, 07 Jan 2010 05:06:31 GMT

  see some problems here:

// Bind the data efficiently with the holder.
(position)).g etTitle()));
(positi on)).getDescription()));
Drawable d = null;
FeedMessage fm = (FeedMessage) Items.get(position);

if that Items.get(position) is costly, you're wasting it, above. How

// Bind the data efficiently with the holder.
Drawable d = null;
FeedMessage fm = (FeedMessage) Items.get(position);

On Jan 6, 12:57pm, Patrick Plaatje <> wrote:
> >

Using an image in a listview

by Patrick Plaatje » Thu, 07 Jan 2010 05:20:33 GMT

 i Brion,

if this arraylist would be a rather big list, it would be costly
indeed, and it is a good suggestion. This list consists of just 10
items (feedmessage objects) though. These feedmessages are just a set
of getters and setters (of just small String objects) and are not doin
any costly operations internally.

I will try your suggestion though to see if this will help. I'm kinda
clueless on what is so costly............

Thanx for the suggestions, and will let you know tomorrow!



2010/1/6 Brion Emde <>:
>> >

Using an image in a listview

by Patrick Plaatje » Thu, 07 Jan 2010 18:05:18 GMT


i've tried the list13 implementation, but although scrolling seems
smoother then it ever was, i'm kinda displeased with the time it takes
to fill the rows with content. I think my main concern is related to
the reuse of the rows, rather then how to fill them. I am wondering if
there isn't a way to prefill the listview and don;t reuse anything?



2010/1/6 Patrick Plaatje <>:
>>> >

Other Threads

1. Screen off suspends the Thread

Hi All,
I have a created a thread in my application, and have a sleep for 5sec
in the run() function. This sleep function returns properly after 5
secs only if the device screen is turned ON. In case the device screen
goes to Hibernate, sleep function returns after around 2-3
minutes(instead of 5 sec).

Have any one faced this issue earlier?



2. How to fix "java.lang.IllegalThreadStateExeception: Thread already started."

I made an application which has a thread for a notification

First time I started the thread, it works fine.
But Second time I tried to start the thread again, the application
stop with the exception.

How can I solve this problem?
Please give me any clue.

[==========My thread code below==================]
private class ProgressThread extends Thread {
        Handler mHandler;
        final static int STATE_DONE = 0;
        final static int STATE_RUNNING = 1;
        int outIncreamentPercent;
        int mState;

        ProgressThread(Handler h) {
                mHandler = h;

        public void run() {
                int i = 0;
                while (mState == STATE_RUNNING) {

                        if (i > MAX_LOOP_COUNT) {
                        } else {
                                if (i % 100 == 0) {
                                        outIncreamentPercent = (int) (((float) 
100,outIncreamentPercent, false);

                                        try {
                                        } catch (InterruptedException e) {
                                                // TODO Auto-generated catch 
                        i = i + LOOP_INCREMENT;
        } /* sets the current state for the thread, * used to stop the thread
        public void setState(int state) {
                mState = state;


3. Getting information from webview

4. Disable hardware codecs

5. SyncAdapter 2.x question

6. SectionIndexer problem

7. HowTo: Supporting devices with different resolutions