I custom the BaseAdapter to show image array with full-screen mode. I want the user can flick the images so I use the gallery class.When a image displays on the screen, a correlative sentence should be showed as well.
The issue is the position param in getView function jump abnormally, especially when I flick into more one picture at a time. Therefore the string is showed incorrectly, I don't know why the image still displays normally. Here is my code: public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Integer[] mImageIds = { R.drawable.number1, R.drawable.number2, R.drawable.number3, R.drawable.number4, R.drawable.number5, R.drawable.number6, R.drawable.number7, R.drawable.number8, R.drawable.number9, R.drawable.number10 }; private String[] captions = { "1. How ", "2. How ", "3. How ", "4. How ", "5. How ", "6. How ", "7. What ", "8. How ", "9. How ", "10. What " }; public ImageAdapter(Context c) { mContext = c; TypedArray a = c.obtainStyledAttributes(Gallery1); mGalleryItemBackground = a.getResourceId( Gallery1_android_galleryItemBackground, 0); a.recycle(); } 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) { ImageView i = new ImageView(mContext); Log.i("position"," == "+ position); i.setImageResource(mImageIds[position]); textview.setText(captions[position]); i.setLayoutParams(new Gallery.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setBackgroundResource(mGalleryItemBackground); return i; } } ================= Please let me know if you have any idea. Thanks in advance. -- 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