我正在尝试通过适配器将图像通过URL加载到我的ListView,但AQuery似乎没有将URL加载到ImageViews。我试过用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中留下空白。我做错了什么?