I'm trying to load images through a URL to my ListView through an adapter but AQuery doesn't seem to load the URLs to the ImageViews. I have tried doing this with Picasso Image Loader and it worked but I prefer AQuery and I need to resolve this issue. I'm using 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;
}
}
The application loads the 'name' fields properly in the ListView but leaves a blank in the ImageView. What am I doing wrong?
use picasso to image downloading and caching library for Android