2012-07-20 78 views
0

我的老板说我要使用Android查询负载ListView中的图像异步的,我发现这个网站:http://code.google.com/p/android-query/wiki/ImageLoading 但是我试着用:(安卓)从URL

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

在我的代码,但我得到这个错误: “aq不能解决” 我必须做什么来初始化aq,我必须导入一些库?

这是我的列表视图适配器: public static class ListViewAdapterWall extends BaseAdapter {0}私有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; 
    } 
+0

尝试用'AQuery含水=新AQuery(上下文);' – 2012-07-20 06:26:30

回答

0

我不得不在互联网上搜索的lib上:Android的查询0.22.10.jar并把它放在我的libs文件夹,它的工作

1

AQuery是围绕视图的包装。

初始化它如下

AQuery aq = new AQuery(imageView); 

这个片段是你提到的同一页!

+0

同样认为与ImageView的,上下文或convertView。该行得到这个错误: 多个标记在该行 \t - AQuery不能被解析为一个类型 \t - AQuery不能被解析为一个类型 – 2012-07-20 06:37:05

+0

你添加库正确呢? – 2012-07-20 06:42:54

+0

我必须添加什么库?他们不是自己添加吗?或者至少他应该在错误中提示我:添加import.dontknowname? – 2012-07-20 06:52:49

0

安卓查询ImageLoading具有再循环()方法。从android_query

的Javadoc说,再循环()方法作为

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

,这里是源调整上述方法。

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; 
}