Re: [android-developers] Re: Using an image in a listview
Hi, 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? Regards, Patrick 2010/1/6 Patrick Plaatje pplaa...@gmail.com: Hi 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! Best, Patrick 2010/1/6 Brion Emde brione2...@gmail.com: I see some problems here: // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get (position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get (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 about: // Bind the data efficiently with the holder. Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); holder.titleText.setText(Html.fromHtml(fm.getTitle ())); holder.descriptionText.setText(Html.fromHtml (fm.getDescription())); On Jan 6, 12:57 pm, Patrick Plaatje pplaa...@gmail.com wrote: Hi, 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: @Override 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, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(positi on)).getDescription())); 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 = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: 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? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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
[android-developers] Re: Using an image in a listview
Are you using any of the techniques shown in the List13.java example in the APIDemos? I have a video example of what can be achieved with such techniques, here: http://www.youtube.com/watch?v=QZ8PoS6ai6U On Jan 6, 8:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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
Re: [android-developers] Re: Using an image in a listview
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. Patrick 2010/1/6 Brion Emde brione2...@gmail.com: Are you using any of the techniques shown in the List13.java example in the APIDemos? I have a video example of what can be achieved with such techniques, here: http://www.youtube.com/watch?v=QZ8PoS6ai6U On Jan 6, 8:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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 -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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
[android-developers] Re: Using an image in a listview
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? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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
Re: [android-developers] Re: Using an image in a listview
Hi, 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: @Override 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, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).getTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).getDescription())); 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 = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: 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? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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 -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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
[android-developers] Re: Using an image in a listview
I see some problems here: // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get (position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get (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 about: // Bind the data efficiently with the holder. Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); holder.titleText.setText(Html.fromHtml(fm.getTitle ())); holder.descriptionText.setText(Html.fromHtml (fm.getDescription())); On Jan 6, 12:57 pm, Patrick Plaatje pplaa...@gmail.com wrote: Hi, 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: @Override 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, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(positi on)).getDescription())); 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 = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: 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? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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 -- Met vriendelijke groet, Patrick Plaatje NDC|VBK de uitgevers Sixmastraat 32, 8915 PA Leeuwarden Postbus 394, 8901 BD Leeuwarden T (058) - 284 5044 M (06) - 158 966 34 -- 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
Re: [android-developers] Re: Using an image in a listview
Hi 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! Best, Patrick 2010/1/6 Brion Emde brione2...@gmail.com: I see some problems here: // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get (position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get (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 about: // Bind the data efficiently with the holder. Drawable d = null; FeedMessage fm = (FeedMessage) Items.get(position); holder.titleText.setText(Html.fromHtml(fm.getTitle ())); holder.descriptionText.setText(Html.fromHtml (fm.getDescription())); On Jan 6, 12:57 pm, Patrick Plaatje pplaa...@gmail.com wrote: Hi, 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: @Override 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, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder.titleText = (TextView) convertView.findViewById(R.id.article_title); holder.descriptionText = (TextView) convertView.findViewById(R.id.article_description); holder.icon = (ImageView) convertView.findViewById(R.id.article_thumb); convertView.setTag(holder); } else { // get holder back...much faster than inflate holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.titleText.setText(Html.fromHtml(((FeedMessage)Items.get(position)).g etTitle())); holder.descriptionText.setText(Html.fromHtml(((FeedMessage)Items.get(positi on)).getDescription())); 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 = _context.getResources().getDrawable(R.drawable.thumb_holder); holder.icon.setImageDrawable(d); } if(fm.getGuid() != null){ convertView.setId(position); } return convertView; } static class ViewHolder { TextView descriptionText; TextView titleText; ImageView icon; } regards, Patrick 2010/1/6 Vince specialized...@gmail.com: 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? Vince On Jan 6, 10:18 am, Patrick Plaatje patrick.plaa...@ndcvbk.nl wrote: 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? Thanx, Patrick -- 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