开发者

Using a HorizontalScrollView with ImageView's over Gallery LazyLoad?

Okay I have an idea and I want to know what you all think.

So for my project I have an gallery. I want to load ima开发者_如何学编程ges into the gallery using Lazyloading But lazyloading doesnt seem to work to well with Gallery. It seems it works better with just having a imageview.

I just cant figure out how to get it to work correctly with Gallery.

I was wondering if I had a horizontalscrollview with many images I need to do this work Can it be efficient?


Look here: SO

This is part of one of my Galleries that is feed with LazyLoadinng. I use a DrawableCache to hold the images that I load from the web. It's working perfect.


What's wrong with just using a simple adapter?

public class MyActivity extends Activity {
    @Override public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Gallery gallery = new Gallery(this);
    gallery.setAdapter(new MyApater());

    setContentView(gallery);
}

private class MyAdapter extends BaseAdapter {
        /** Make sure your list gets populated somehow. */
    List<Integer> mContent = new ArrayList<Integer>()
        {
            mContent.add(R.drawable.d1);
            mContent.add(R.drawable.d2);
            ...
        };

    @Override public int getCount() { return mContent.size(); }
    @Override public Object getItem(int position pos) {
        return mContent.get(pos);
    }
    @Override public long getItemId(int pos) {
        return pos;
    }

    @Override public View getView(int postition, View view ViewGroup vg) {
        /** Inflate your view here. (using the resource id's of mContent) */
        return (ImageView)findViewById(mContent.get(pos));
    }
}

}

EDIT:

Sory if I missed the point, I'm not familier with the term 'lazy loading'.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜