musa
musa

Reputation: 1465

Android slow gallery view

I'm using a gallery in 20 pictures, but thumbnail scroll is too slow and lagging.
but I'm try someone else's gallery in 90 pictures no lag and speed.

Why my gallery might be slow?

public View getView(int position, View convertView, ViewGroup parent) {
   ImageView imgView = new ImageView(context);
   imgView.setImageResource(main.gallery.get(position)); 
   imgView.setLayoutParams(new Gallery.LayoutParams(80, 80));
   imgView.setScaleType(ImageView.ScaleType.FIT_XY);
   imgView.setBackgroundResource(GalItemBg);
   return imgView;
}

Edit: Problem is solved with a good example, here Android GalleryView Recycling

Upvotes: 1

Views: 2515

Answers (3)

Karthik
Karthik

Reputation: 5033

You could use View Flipper for image gallery which you can use it for larger no of pictures,this would load to your app dynamically.

Upvotes: 0

mcwong
mcwong

Reputation: 783

Download quickpic app as replacement for gallery.

Upvotes: 0

anon
anon

Reputation:

You should try to "recycle" views and not always create a new one. For that you can use the passed parameter convertView.

Upvotes: 1

Related Questions