我想根据不起作用的条件更改与每个项目关联的图像。项目没有重复,但图像正在重复
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.search_shopping_items,
null);
holder = new ViewHolder();
holder.txt = (TextView) convertView
.findViewById(R.id.TextView01);
holder.imgFavHis=(ImageView) convertView.findViewById(R.id.imgFavHis);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if(LocalDb.isLoggedIn()){
holder.txt.setText( arr.get(position));
if(hisList.contains(arr.get(position))){
holder.imgFavHis.setImageResource(R.drawable.icnhistory);
}
else if (favList.contains(arr.get(position)) ){
holder.imgFavHis.setImageResource(R.drawable.icnfavorite);
}
}
else{
holder.txt.setText(arr.get(position));
}
return convertView;
}
}