0

My boss said I have to use Android Query, and i found this site: http://code.google.com/p/android-query/wiki/ImageLoading But i tried with:

  aq.id(R.id.image1).image("http://www.vikispot.com/z/images/vikispot/android-w.png");

In my code, but i get this error: "aq cannot be resolved" What do i have to do to initialize that aq, do i have to import some lib?

This is my list view adapter: public static class ListViewAdapterWall extends BaseAdapter { private LayoutInflater mInflater;

    public ListViewAdapterWall(Context context) {

        mInflater = LayoutInflater.from(context);

    }

    public int getCount() {
        return ListviewContentWall.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        ListContent holder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.listviewinflate, null);

            holder = new ListContent();
            holder.wallImage = (ImageView) convertView
                    .findViewById(R.id.wallImage1);
            holder.wallButton = (ImageButton) convertView
                    .findViewById(R.id.wallButton1);


            convertView.setTag(holder);
        } else {

            holder = (ListContent) convertView.getTag();
        }

        AQuery aq = new AQuery(convertView);

        aq.id(R.id.wallImage1).image("http://www.vikispot.com/z/images/vikispot/android-w.png");
        //holder.wallImage.setBackgroundDrawable(ListviewContentWall.get(position));
        //holder.wallButton.setBackgroundDrawable(ListviewContentWall.get(position));
        //holder.text2.setText(ListviewContent2.get(position));

        return convertView;
    }
rosu alin
  • 5,674
  • 11
  • 69
  • 150

3 Answers3

1

AQuery is a wrapper around a View.

Initialize it as follows

AQuery aq = new AQuery(imageView);

This snippet is from the same page that you mentioned!

Vikram Bodicherla
  • 7,133
  • 4
  • 28
  • 34
  • Same think with imageView,context or convertView. That line gets this error: Multiple markers at this line - AQuery cannot be resolved to a type - AQuery cannot be resolved to a type – rosu alin Jul 20 '12 at 06:37
  • Did you add the library properly then? – Vikram Bodicherla Jul 20 '12 at 06:42
  • What library do i have to add? Don't they add themselves? or at least he should asc me at the errors to: add import.dontknowname ? – rosu alin Jul 20 '12 at 06:52
0

I had to search on the internet for the lib: android-query-0.22.10.jar and put it in my libs folder for it to work

rosu alin
  • 5,674
  • 11
  • 69
  • 150
0

Android Query ImageLoading has recycle() methods.

Javadoc from android_query says, recycle() method as

public T recycle(View root) Recycle this AQuery object. The method is designed to avoid recreating an AQuery object repeatedly, such as when in list adapter getView method.

Parameters:

root - The new root of the recycled AQuery.

Returns:

self

and here is source adjust above method.

AQuery listAq = new AQuery(this);

public ListViewAdapterWall(Context context) {
    mInflater = LayoutInflater.from(context);
}

public int getCount() {
    return ListviewContentWall.size();
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {

    ListContent holder;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.listviewinflate, null);

        holder = new ListContent();
        holder.wallImage = (ImageView) convertView
                .findViewById(R.id.wallImage1);
        holder.wallButton = (ImageButton) convertView
                .findViewById(R.id.wallButton1);


        convertView.setTag(holder);
    } else {

        holder = (ListContent) convertView.getTag();
    }

    AQuery aq = listAq.recycle(convertView);

    aq.id(R.id.wallImage1).image("http://www.vikispot.com/z/images/vikispot/android-w.png");
    //holder.wallImage.setBackgroundDrawable(ListviewContentWall.get(position));
    //holder.wallButton.setBackgroundDrawable(ListviewContentWall.get(position));
    //holder.text2.setText(ListviewContent2.get(position));

    return convertView;
}
Daeyeol Ryu
  • 76
  • 1
  • 3