我有一个自定义适配器来在 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项时,它会下载相应的文件,并且ProgressBar使可见。但是当我调用 notifyDatasetChanged() 时,进度条保持其初始状态。
即使调用 notifyDatasetChanged(),我如何保持/显示进度条的状态/进度?
谢谢