Android Query ListView图片加载

我已将listview适配器的代码包含在下面所有工作正常,但图像未从网址加载.可能是这样的.我正在使用Android查询库来加载图片.

  public Onadapter(Context context,String[] id,String[] label,String[] title,String[] image,String[] hrs,String[] posted_date)
    {
        this.context=context;
        this.id = id;
        this.label = label;
        this.title = title;
        this.image = image;
        this.hrs = hrs;
        this.posted_date=posted_date;


    }

    private class ViewHolder{
        ImageView img;
        TextView id;
        TextView label;
        TextView title;
        TextView hrs;
        TextView posted_date;

    }
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.whatslist, null);
            holder = new ViewHolder();
            holder.id=(TextView) convertView.findViewById(R.id.whats_id);
            holder.img = (ImageView) convertView.findViewById(R.id.thumb1);
            holder.label= (TextView) convertView.findViewById(R.id.label);
            holder.title = (TextView) convertView.findViewById(R.id.artist_e_desc);
            holder.hrs = (TextView) convertView.findViewById(R.id.hrs);
            holder.posted_date = (TextView) convertView.findViewById(R.id.date);

            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.id.setText(id[position]);
        holder.label.setText(label[position]);
        holder.title.setText(title[position]);
        holder.hrs.setText(hrs[position]);
        holder.posted_date.setText(posted_date[position]);
        imgaq = new AQuery(convertView);
        imgaq.id(holder.img).image(image[position], true, true, 0, 0, null, AQuery.FADE_IN_NETWORK, 1.0f);
        return convertView;
    }


    @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return image.length;
        }


        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }


        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return null;
        }




}

解决方法:

也许你最好使用recycle()

我认为在getView()方法中每次都不是新方法.

AQuery listAq = new AQuery(this);

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;

    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.whatslist, null);
        holder = new ViewHolder();
        holder.id=(TextView) convertView.findViewById(R.id.whats_id);
        holder.img = (ImageView) convertView.findViewById(R.id.thumb1);
        holder.label= (TextView) convertView.findViewById(R.id.label);
        holder.title = (TextView) convertView.findViewById(R.id.artist_e_desc);
        holder.hrs = (TextView) convertView.findViewById(R.id.hrs);
        holder.posted_date = (TextView) convertView.findViewById(R.id.date);

        convertView.setTag(holder);
    }
    else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.id.setText(id[position]);
    holder.label.setText(label[position]);
    holder.title.setText(title[position]);
    holder.hrs.setText(hrs[position]);
    holder.posted_date.setText(posted_date[position]);

    AQuery imgaq = listAq.recycle(convertView);
    imgaq.id(holder.img).image(image[position], true, true, 0, 0, null, AQuery.FADE_IN_NETWORK, 1.0f);
    return convertView;
}
上一篇:(转)python logging日志模块以及多进程日志


下一篇:Python--return后进行回调方法