android - AQuery 不会在 Android Studio 中加载图像

标签 android android-activity listview-adapter aquery

我正在尝试通过适配器通过 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 中正确加载“名称”字段,但在 ImageView 中留下空白。我做错了什么?

最佳答案

使用picasso到Android的图像下载和缓存库

关于android - AQuery 不会在 Android Studio 中加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30309839/

相关文章:

android - 在 Android 上以编程方式检测和更改数据连接 (GPRS/UMTS)

java - 使用 KeyGaurdManager 锁定 Android 确认凭据屏幕的方向

java - 点击通知后如何正确地将新 Activity 添加到堆栈顶部

android - 如何在 BaseAdapter Get View 方法扩展的类中显示 Toast

android - 未显示简单 Android fragment 的框架

Android改变ListView字体

android - SharedUserId 访问 SharedPreferences

java - 不幸的是, "GoogleMapsV2"已停止

android - JSON异常 : Value -- array hasn't got a label

java - 如何通过 Activity 传递 List<自定义对象>