我发现了一些类似的问题,但无法解决问题。我有一个自定义Listview,其中每个项目包含一个水平进度条。但是当列表包含许多项目时,我使用滚动条浏览列表视图,一些ProgressBars会消失。是什么导致这种情况以及如何解决?
public class AdapterMetas extends ArrayAdapter<Metas>{
private int resource;
private Context mContext;
public AdapterMetas(Context context) {
super(context, R.layout.adaptermetas);
this.resource = R.layout.adaptermetas;
mContext = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Metas p = getItem(position);
LinearLayout layout = null;
if (convertView == null) {
LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) li.inflate(resource, null);
} else {
layout = (LinearLayout) convertView;
}
int value = p.getiValueMeta();
ProgressBar itemMetaBar = (ProgressBar) layout.findViewById(R.id.itemMetaBar);
itemMetaBar.setProgress(value);
return layout;
}
}