开发者

Droidfu WebImageView and GridView problem

Im using Droidfu's widget WebImageView inside GridView to create gallery. Image is beeing async downloaded with WebImageView and cached.

The problem is that id doesn't always show the image (it shows default error img instead) when grid scrolls to it. It's like getView is destroying it and not being able to recycle it every time properly.

This is my GridAdapter

public class GalleryAdapter extends BaseAdapter {

    private Context mContext;

    public GalleryAdapter(Context c) {
        // TODO Auto-generated constructor stub
        mContext = c;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return theList.getItemCount();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return theList.getItem(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        final GalleryItem galeryItem = theList.getItem(position);

        if (convertView == null) {
            convertView = (View) getLayoutInflater().inflate(R.layout.gallery_item, parent, false);

        }

        WebImageView imageView = (WebImageView) convertView.findViewById(R.id.webimage);

        if (!galeryItem.getMain_image().trim().equalsIgnoreCase("")) {  

            imageView.setScaleType(ScaleType.CENTER_CROP);
            imageView.setAdjustBounds(true);
            ima开发者_开发知识库geView.reset();
            imageView.setImageUrl(galeryItem.getMain_image().trim());
            imageView.setNoImageDrawable(R.drawable.heading_img_bg);
            imageView.loadImage();
        }

        TextView heading = (TextView) convertView.findViewById(R.id.gallery_heading);
        heading.setText(galeryItem.getHeading());

        TextView img_num = (TextView) convertView.findViewById(R.id.gallery_img_num);
        img_num.setText(Integer.toString(galeryItem.getImage_num()));   

        return convertView;
    }

}


According to this, development on Droid-Fu is going to stop and it will be 'rebranded' as Ignition.

Ignition has a similar class called RemoteImageView. Usage is basically the same but it appears they've reworked the back end a bit. I tried it with a ListView that was giving the loading forever problem. Worked for me (although it introduced some other problems).

You can give it a go and see if your problem has been addressed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜