I've tried to describe this problem a few times, but I'll try again.
I have a thread (not spawned from the adapter) which updates items in
a List that a BaseAdapter child uses to populate its view. I am not
adding things in the List from the thread, just modifying content. In
any case, I have 6 rows visible at first on the screen. The thread
pulls data from the network and updates them in 0, 1, 2, 3, 4, 5
order. However, when 0 is updated, 5 mirrors its data on the screen
briefly, then 1 is updated, 4 mirrors it, 3 is updated, then 4 is
reloaded correctly, then 5, then 6. I am using the view holder/
convertView pattern correctly, as far as I can tell.
How many views are created by default for an adapter? My guess is 3
based on what I see. Then, when getView() gets to index 4, 5, or 6, it
correctly creates more Views and populates the right data. Anyone ever
seen anything like this?
getView() impl (the appMap values are the same as the appList):
public View getView(int position, View convertView, ViewGroup parent)
{
if (position >= appList.size()) {
return null;
}
ViewHolder holder;
if (convertView == null) {
convertView =
mInflater.inflate(R.layout.app_list_item, null);
// Creates a ViewHolder and store references to
the two children
views
// we want to bind data to.
holder = new ViewHolder();
holder.appName = (TextView)
convertView.findViewById
(R.id.app_list_item_name);
holder.appIcon = (ImageView)
convertView.findViewById
(R.id.app_list_item_icon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ObjectToShow objectToShow = appList.get(position);
ObjectToShow objectToShowWithMetadata = appMap.get
(objectToShow.getKey());
if(objectToShow != null) {
if(objectToShowWithMetadata.getName() != null) {
holder.appName.setText(objectToShowWithMetadata.getName());
}
if(iconMap.get(objectToShow.getKey()) != null) {
holder.appIcon.setImageBitmap(iconMap.get(objectToShow.getKey
()));
}
} else {
holder.appName.setText(defaultText);
holder.appIcon.setImageDrawable(defaultIcon);
}
return convertView;
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---