If the convertView is always null and all the views you create are
kept in the Gallery's recycler, there's definitely a bug. I would like
to know however what is the size (in pixels) of the images you load in
the Gallery.

On Wed, Dec 3, 2008 at 10:45 PM, EboMike <[EMAIL PROTECTED]> wrote:
>
> I've already asked this in <a href="http://groups.google.com/group/
> android-developers/msg/9cdbf47be2505810?hl=en">This thread</a>: Here
> is a pretty simple Gallery setup. It seems to leak with every image
> that's loaded (see the original thread for details).
>
> I'm tempted to file it as a bug, but I want to mention it here first
> to make sure I'm not just making a simple mistake in my usage of the
> Gallery. Also (as mentioned in another thread), convertView is always
> null -- the Gallery never seems to recycle any views. Why?
>
> To make this run, you will need to put a JPG file into the data folder
> (see code).
>
>
> package ebomike.memorytest;
>
> import android.app.Activity;
> import android.content.Context;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.graphics.drawable.BitmapDrawable;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.view.ViewGroup;
> import android.widget.BaseAdapter;
> import android.widget.Gallery;
> import android.widget.ImageView;
>
> public class MemoryTest extends Activity {
>
>        Gallery g;
>
>    /** Called when the activity is first created. */
>    @Override
>    public void onCreate(Bundle savedInstanceState) {
>
>                String filePath;
>
>                // NOTE: Make this point to a JPEG file.
>                filePath = getFilesDir().getPath();
>                filePath += "/TEST_IMAGE.jpg";
>
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.main);
>
>        g = (Gallery) findViewById(R.id.Gallery01);
>        g.setAdapter(new FullImageAdapter(this, filePath));
>    }
>
>    class FullImageAdapter extends BaseAdapter
>    {
>        Context context;
>        String path;
>
>        FullImageAdapter(Context c, String path)
>        {
>                context = c;
>                this.path = path;
>        }
>
>        public int getCount()
>        {
>                return 1024;
>        }
>
>        public int getViewTypeCount()
>        {
>                return 1;
>        }
>
>        public boolean hasStableIds()
>        {
>                return true;
>        }
>
>        public int getItemViewType(int position)
>        {
>                return 0;
>        }
>
>        public View getView(int position, View convertView, ViewGroup
> parent)
>        {
>                ImageView view;
>
>                if (convertView != null)
>                {
>                        // Note that we never get here. Why?
>                        view = (ImageView) convertView;
>                }
>                else
>                {
>                        view = new ImageView(context);
>                }
>
>                Bitmap bitmap = BitmapFactory.decodeFile(path);
>                BitmapDrawable drawable = new BitmapDrawable(bitmap);
>                view.setImageDrawable(drawable);
>
>                return view;
>        }
>
>        public Object getItem(int position)
>        {
>                return position;
>        }
>
>        public long getItemId(int position)
>        {
>                return position;
>        }
>    }
> }
>
> The layout:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>    android:orientation="vertical"
>    android:layout_width="fill_parent"
> android:layout_height="fill_parent">
> <TextView
>    android:layout_width="fill_parent"
>    android:layout_height="wrap_content"
>    android:text="@string/hello"
>    />
> <Gallery android:id="@+id/Gallery01"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"></Gallery>
>
> </LinearLayout>
>
>
> >
>



-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to