我有一個自定義的適配器來顯示gridview中的一些圖像。如何更新除進度條外的適配器?
public class CustomAdapter extends BaseAdapter {
private Context context;
ArrayList<String> list = null;
public CustomAdapter (Context context, ArrayList<String> list) {
this.context = context;
this.list = list;
}
l
public int getCount() {
return list.size();
}
public Object getItem(int paramInt) {
return paramInt;
}
public long getItemId(int paramInt) {
return paramInt;
}
public View getView(int position, View child, ViewGroup parent) {
String string= list.get(position);
Bitmap bitmap = null;
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.grid_item, null);
RelativeLayout parentLayout = (RelativeLayout) view
.findViewById(R.id.parentLayout);
ImageView iView = (ImageView) view.findViewById(R.id.imageView);
final ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress);
if (string != null) {
bitmap = BitmapFactory.decodeFile(string);
} else {
bitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.img_loading);
}
iView.setImageBitmap(bitmap);
iView.setTag(position);
return view;
}
}
這是gridview的適配器。當選擇gridview項目時,它下載一個相應的文件,並且進度條變得可見。但是,當我調用notifyDatasetChanged()時,進度條會保留其初始狀態。
即使notifyDatasetChanged()被調用,我如何保持/顯示進度條的狀態/進度?
感謝