1

我发现了一些类似的问题,但无法解决问题。我有一个自定义 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;
    }


}
4

0 回答 0