This is a known "bug" (it's not a bug really, we just never had the time to implement recycling in Gallery) but we have no ETA for a fix.
On Wed, May 26, 2010 at 8:31 PM, Aamir Shah <aamirns...@gmail.com> wrote: > I am using the Hello Gallery code as an example. Views are not being > recycled as I scroll left and right. > > I added log output at the getView method, and I get a constant output > of null. Anyone know the reason why? > > Here is the code: > > public class HelloGallery extends Activity { > > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > > Gallery g = new Gallery(this); > g.setAdapter(new ImageAdapter(this)); > > setContentView(g); > } > > public class ImageAdapter extends BaseAdapter { > int mGalleryItemBackground; > private Context mContext; > > private Integer[] mImageIds = { > R.drawable.sample_1, > R.drawable.sample_2, > R.drawable.sample_3, > R.drawable.sample_4, > R.drawable.sample_5, > R.drawable.sample_6, > R.drawable.sample_7 > }; > > public ImageAdapter(Context c) { > mContext = c; > > } > > public int getCount() { > return mImageIds.length; > } > > public Object getItem(int position) { > return position; > } > > public long getItemId(int position) { > return position; > } > > public View getView(int position, View convertView, ViewGroup > parent) { > System.out.println(convertView); //should occasionally not be > null > ImageView i = new ImageView(mContext); > > i.setImageResource(mImageIds[position]); > i.setLayoutParams(new Gallery.LayoutParams(150, 100)); > i.setScaleType(ImageView.ScaleType.FIT_XY); > i.setBackgroundResource(mGalleryItemBackground); > > return i; > > > } > } > > Thanks, > Aamir > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en