您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
解决办法:看代码
package com.zhiren.coaltransportsystem.adapters; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import com.zhiren.coaltransportsystem.R; import com.zhiren.coaltransportsystem.activities.Stationed_List_Activity; import com.zhiren.coaltransportsystem.bean.ChoseAddressBean; import java.util.List; /** * Created by Administrator on 2016/6/3. */ public class LocationAdapter extends BaseAdapter { private Context context; private List list; private ImageView icon; private Handler handler; public LocationAdapter(List list, Context context, Handler handler) { this.list = list; this.context = context; this.handler = handler; } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return list.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (position > list.size() || position < 0) { return convertView; } ViewHolder viewHolder = null; if (convertView == null) { viewHolder = new ViewHolder(); convertView = View.inflate(context, R.layout.find_address_item, null); viewHolder.iv_icon_chose = (ImageView) convertView.findViewById(R.id.iv_icon_chose); viewHolder.tv_addressname_item = (TextView) convertView.findViewById(R.id.tv_addressname_item); viewHolder.rl_icon_item = (RelativeLayout) convertView.findViewById(R.id.rl_icon_item); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.iv_icon_chose.setVisibility(View.GONE); final ChoseAddressBean choseAddressBean = (ChoseAddressBean) list.get(position); viewHolder.tv_addressname_item.setText(choseAddressBean.name); final ViewHolder finalViewHolder = viewHolder; viewHolder.rl_icon_item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { icon.setVisibility(View.GONE); finalViewHolder.iv_icon_chose.setVisibility(View.VISIBLE); icon = finalViewHolder.iv_icon_chose; Message msg = Message.obtain(); msg.obj = choseAddressBean.name; msg.what = Stationed_List_Activity.NEW_ADDRESS; handler.sendMessage(msg); } }); if (position == 0) { viewHolder.iv_icon_chose.setVisibility(View.VISIBLE); icon = viewHolder.iv_icon_chose; } return convertView; } static class ViewHolder { private ImageView iv_icon_chose; private TextView tv_addressname_item; private RelativeLayout rl_icon_item; } }
出现图片错乱显示的问题是因为快速翻动复用了View,那么每次将其重置即可。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。