EcoGallery
EcoGallery copied to clipboard
getView() in BaseAdapter being called infinitely
I have some basic getView() code that is as follows:
public View getView(int position, View convertView, ViewGroup viewGroup) { View v = inflater.inflate(R.layout.gallery_image_layout, null); ImageView i = (ImageView) v.findViewById(R.id.houseImage); i.setLayoutParams(new FrameLayout.LayoutParams(pictureWidth, FrameLayout.LayoutParams.MATCH_PARENT)); FrameLayout layout = (FrameLayout) v .findViewById(R.id.rootFrameLayout); layout.setLayoutParams(new EcoGallery.LayoutParams(pictureWidth, EcoGallery.LayoutParams.MATCH_PARENT)); House h = getItem(position); AQuery aq = new AQuery(mContext); aq.id(i).image(h.thumbnailURL, true, true, pictureWidth, 0); return v; }
When using AQuery it seems to never stop calling getView() and the gallery is blank with nothing there. Changing the two lines out to a simple ImageView.setImageResource() fixes it.
Any idea what's going on?
I think you're supposed to recycle aquery… as in
in your getView() { final AQuery aq = mListAq.recycle(convertView); // use this local aq instance. }
and mListAq you initialize as a field in the constructor of your adapter (only once)
mListAq = new AQuery(yourContext);
(read AQuery documentation if you need more info)