Each item in my ListView
containt an ImageView
and a TextView
, this will be filled with remote information.
I got an URL for t
I tried using fill_parent as height in ListView but i was unable to achieve it perfect but how ever i tried it by preventing creating convertViews if it its already exist. it works fine in my appoach.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView != null)
return convertView;
else {
//your code...
}
}
i recommend you to watch this video http://www.youtube.com/watch?v=wDBM6wVEO70
basically android will call getView multiple times for it's calculation of view heights and stuff, so you need to implement some sort of cache in your async, check http://code.google.com/p/android-query/ which has that if you don't use authentication
Sorry for late reply. I had been facing the same problem in my adapter for gallery widget. I had employed Universal Image Loader. Martijn's solution worked for me. What all I had to do was to add notifyDataSetChanged() when the image had been completely downloaded and imageView was being set.
The problem was in the Layout of the ListView.
The parameter layout_width
was set to wrap_content
when I changed it to fill_parent
the problem disappeared...
The problem is that your ListView does not know what the of each item is. When initializing, the ListView will measure all of its children and draw itself upon this information. What you are doing with your AsyncTask, is changing the sizes of the items in the list and not letting the ListView draw itself again completely. This results in your ListView to behave strangly.
Solution: You should update your ListView by notifying the Adapter using notifyDataSetChanged() in the PostExecute of your AsyncTask. This will allow the ListView to draw itself with the new information.
I hope it works !
A few helpfull links:
http://thinkandroid.wordpress.com/2012/06/13/lazy-loading-images-from-urls-to-listviews/
Lazy load of images in ListView