我有一个从 arrayadapter 扩展的自定义适配器:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.list_item, null);
holder = new ViewHolder();
holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
holder.tvPrice = (TextView) convertView.findViewById(R.id.tvPrice);
holder.ivItem = (ImageView) convertView.findViewById(R.id.ivItem);
holder.ivIcon = (ImageView) convertView.findViewById(R.id.ivIcon);
holder.ivArrow = (ImageView) convertView.findViewById(R.id.ivArrow);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tvName.setText(item.get(position).getName());
holder.tvPrice.setText(item.get(position).getPrice());
holder.ivItem.setImageBitmap(item.get(position).getAvatar());
holder.ivArrow.setImageDrawable(item.get(position).getArrow());
holder.ivIcon.setImageDrawable(item.get(position).getIcon());
holder.ivIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/*...My code...*/
}
});
return convertView;
}
我尝试单击 item ivIcon
,listview
将删除一行并listview
刷新,但我无法刷新 listview。我需要帮助