AQuery 不在 Android Studio 中加载图像

AQuery does not load images in Android Studio

我正在尝试通过适配器通过 URL 将图像加载到我的 ListView,但 AQuery 似乎没有将 URL 加载到 ImageView。我曾尝试使用 Picasso Image Loader 执行此操作并且它有效但我更喜欢 AQuery 并且我需要解决此问题。我正在使用 Android Studio。

public class FeedAdapter extends ArrayAdapter<ActivityTable> {

    ArrayList<ActivityTable> activities = new ArrayList<ActivityTable>();
    Context ctx;
    int resource;
    AQuery aq;

    public FeedAdapter(Context context, int resource, ArrayList<ActivityTable> activityList) {
        super(context, resource, activityList);
        this.activities = activityList;
        this.ctx = context;
        this.resource = resource;
    }

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

        View v = convertView;

        if (v == null) {

            LayoutInflater vi;
            vi = LayoutInflater.from(getContext());
            v = vi.inflate(R.layout.newsfeed_single, null);

        }

        ActivityTable p = new ActivityTable(); //Object of type ActivityTable

        for(ActivityTable item: activities) {
            p = activities.get(position);
        }

        if (p != null) {

            TextView owner_text = (TextView) v.findViewById(R.id.post_owner);
            ImageView post_picture = (ImageView) v.findViewById(R.id.post_media);

             owner_text.setText(p.getUser().getFname());

             AQuery aq = new AQuery(ctx);
             aq.id(R.id.post_media).image(p.getURL()); //getURL() Returns the Image URL 
             //The URL is valid and I checked whether it works through Picasso Image Loader
        }

        return v;

    }
}

应用程序在 ListView 中正确加载 'name' 字段,但在 ImageView 中留下空白。我做错了什么?

使用 picasso 为 Android

的图像下载和缓存库

首先你需要静态 class 像这样 tutorial

在 ViewHolder class 添加字符串 url;

比 getView 添加这个加载

if (viewHolder.url == null || url.equals(viewHolder.url)){
  viewHolder.url = url;
  // load image 
}