I have a custom control in a listview to showing playing progress when I click in a listitem.
When I click in a listitem and when it’s playing the sound I show a progress circle but if I scroll the listview this custom control it’s showing each 6 rows above.
This is my problem:
http://i43.tinypic.com/34dsx2e.png
This is the getView of my CustomAdapter:
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(mResourceId, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.position = position;
Item item = getItem(position);
holder.progressWheel.setPosition(position);
holder.textViewTitle.setText(item.getName());
return convertView;
}
Thanks in advance!
The progress circle appears because you are recycling the convertView (the listview sends you on the convertView param a previously used view to reduce memory usage). There are two solutions:
A) Do not recycle the convertView (sub-obtimal)
Replace:
with:
B) Hide the progressWheel on the view before “return convertview”