我正在自定义列表视图中制作条形图。当我滚动列表时,组件会随机播放。怎么可能阻止。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.stats_row_layout, null);
}
Stat stat = objects.get(position);
if (stat.isFlag()) {
LinearLayout linearLayout = (LinearLayout) convertView.findViewById(R.id.parentLayout);
linearLayout.setVisibility(LinearLayout.VISIBLE);
} else {
LinearLayout linearLayout = (LinearLayout) convertView.findViewById(R.id.parentLayout);
linearLayout.setVisibility(LinearLayout.GONE);
}
if (!stat.isExist()) {
stat.setExist(true);
LinearLayout linearLayout = (LinearLayout) convertView.findViewById(R.id.statGraphLayout);
linearLayout.removeAllViews();
if (stat.getmView() == null) {
ImageView mView = new StatBarChartVie(context, stat.getStatValues());
stat.setmView(mView);
}
LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 50);
stat.getmView().setLayoutParams(params);
linearLayout.addView(stat.getmView());
}
}
return convertView;
}