I have a very bad issue. I have a listview with an adapter.
public class MediaAdapter extends ArrayAdapter<Media> {
public MediaAdapter(Context context, Media[] items) {
super(context, R.layout.mediaitemlist, items);
}
/* private view holder class */
private class ViewHolder {
TextView media_name;
TextView media_path;
TextView media_version;
TextView media_type;
ProgressBar pb;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
View view = convertView;
if (view == null) {
view = (View)LayoutInflater.from(getContext()).inflate(R.layout.mediaitemlist, null);
holder = new ViewHolder();
holder.media_name = (TextView) view
.findViewById(R.id.media_name);
holder.media_path = (TextView) view
.findViewById(R.id.media_path);
holder.media_type = (TextView) view
.findViewById(R.id.media_type);
holder.media_version = (TextView) view
.findViewById(R.id.media_version);
holder.pb = (ProgressBar)view.findViewById(R.id.itemprogressdl);
view.setTag(holder);
//Maybe the problem is here ???????????
getItem(position).setmProgressBar((ProgressBar)view.findViewById(R.id.itemprogressdl));
} else {
holder = (ViewHolder) view.getTag();
}
Media rowItem = (Media) getItem(position);
holder.media_name.setText(rowItem.get_Name());
holder.media_path.setText(rowItem.get_Path());
holder.media_type.setText(rowItem.get_TypeString());
holder.media_version.setText("" + rowItem.get_Version());
rowItem.setmProgressBar(holder.pb);
return view;
}
}
Here, the mediaitemlist Layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="@drawable/listitembackground" >
<TextView
android:id="@+id/media_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/black"
android:textSize="25sp" />
<TextView
android:id="@+id/media_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/media_name"
android:textColor="@android:color/black"
android:visibility="invisible" />
<TextView
android:id="@+id/media_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/media_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/media_version"
android:textColor="@android:color/black" />
<ProgressBar
android:id="@+id/itemprogressdl"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/media_name"
android:layout_below="@+id/media_name"
android:layout_toLeftOf="@+id/media_version"
android:max="100"
android:visibility="invisible"
android:indeterminate="true"/>
</RelativeLayout>
The progressBar is an attribute of a media class. One Media class have is own progress according to his place in the listView.
But, all the progressBar attributes are good, except the first of the listView. If I click on the second or over, I can see the progressBar progresses, but not with the first.
So, why the first progressBar doesn't work and the next work?
If you need more code,comments or other, ask me.