0

Its very weird, but true. I am using ViewHolder pattern to increase the list performance. getView() method has bitmap, but the below code can't render the bitmap in the imageview of listview item.

if (convertView == null) {
    convertView = layoutInflater.inflate(R.layout.item_view_contact_item, null);
    viewHolder = new ViewHolder(convertView);
    convertView.setTag(viewHolder);
} else {
    viewHolder = (ViewHolder) convertView.
}

The above can't render bitmap in list row imageview. But the below code does

//if(convertView == null) {
    convertView = layoutInflater.inflate(R.layout.item_view_contact_item, null);
    viewHolder = new ViewHolder(convertView);
    convertView.setTag(viewHolder);
//} else {
//    viewHolder = (ViewHolder) convertView.
//}

In this case, everything(search, bitmap assignment to imageview) works fine. But this leads to reduction in list performance, as the layout inflation is happening every-time.

Kindly help.

Note: I am downloading the bitmaps in sepatrate AsyncTask, and assigning them in the arraylist, which is initially passed to the Adapter.

  • `Its very weird, but true. I am using ViewHolder pattern to increase the list performance.` It's not **weird**. It's a **best practice**. – Phantômaxx Mar 09 '15 at 20:14
  • `can't render the bitmap in the listview.` and `reduction in list performance`. Sorry but what do you mean? Need any help? With what? – greenapps Mar 09 '15 at 20:24
  • There is an issue with my custom imageview, hence could not render the bitmap. Sorry folks...:( – Noopesh Kumar Mar 11 '15 at 14:02

0 Answers0