我用得是Xutils 然后有的item有图片有的不显示,结果错位了
下面代码:
//图片url
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = View.inflate(getApplicationContext(), R.layout.shequlistadaper, null);
holder.shequtupian1 = (ImageView) convertView.findViewById(R.id.shequtupian1);
holder.shequtupian2 =(ImageView) convertView.findViewById(R.id.shequtupian2);
holder.shequtupian3 = (ImageView) convertView.findViewById}
else {
holder = (ViewHolder) convertView.getTag();
}
//图片url
String p1 =tupian1.get(position).toString();
String p2 =tupian2.get(position).toString();
String p3 =tupian3.get(position).toString();
//加载图片
if(p1.equals("no")){
utils1.display(holder.shequtupian1, p1);
holder.shequtupian1.setVisibility(View.GONE);
}else{
holder.shequtupian1.setVisibility(View.VISIBLE);
utils1.display(holder.shequtupian1, p1);}
viewholder复用出现问题 代码打全
这个问题很复杂,你要做一个缓冲,具体网上案例多如牛毛
你有把viewholder 作为tag设置到convertview上去么?代码里没看到。而且最好给holder添加一个可以唯一辨识的tag,比如position
ViewHolder里的元素有问题