Weird issue: Gallery Widget never calls getView
<p>I am working on a media player for an example application... and things are moving along great... except that when I add my AlbumAdapter to the Gallery Widget... it never calls getView.</p>

<p>Isn't this right?</p>

<pre><code>albumList = getAlbums(mCurrentArtist);
    // updateAlbumArt();
    if (albumList.size() &gt; 0) {
        Log.v("Log", "got here");
        AlbumAdapter coverImageAdapter = new AlbumAdapter();

        Gallery gallery = (Gallery) player.findViewById(R.id.covers);
        gallery.setSpacing(5);
        gallery.setAdapter(coverImageAdapter);
        Log.v("coverImageAdapter", "Count is: "+coverImageAdapter.getCount());
        Log.v("Gallery", "Object: "+gallery.toString()+" Child count: "+gallery.getChildCount());
</code></pre>

<p>There are 13 items in the adapter... I checked. No call to getView is ever made... I have a Log item there that never gets called.</p>

<p>Here is my Adapter class</p>

<pre><code>public class AlbumAdapter extends BaseAdapter {

    class ViewHolder {
        ImageView cover;
    }

    public int getCount() {
        return coverImages.size();
    }

    public Object getItem(int position) {
        return coverImages.get(position);
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        Album album;

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 3;

        Log.v("Gallery", "Position : "+position);
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.cover, null);
            holder = new ViewHolder();
            holder.cover = (ImageView) convertView
                    .findViewById(R.id.albumcover);
            holder.cover
                    .setLayoutParams(new Gallery.LayoutParams(120, 170));
            holder.cover.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (position &gt; getCount()) {

            Bitmap empty = BitmapFactory.decodeResource(getResources(),
                    R.drawable.empty, options);
            Drawable cover = new BitmapDrawable(getResources(), empty);
            cover.setDither(true);
            holder.cover
                    .setLayoutParams(new Gallery.LayoutParams(120, 170));
            holder.cover.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            holder.cover.setImageDrawable(cover);
            Log.v("AlbumAdapter", "Adding cover to fill empty spot");
        } else {
            album = albumList.get(position);
            if (album.cover == null) {
                holder.cover
                        .setLayoutParams(new Gallery.LayoutParams(120, 170));
                holder.cover.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                holder.cover.setImageDrawable(createReflectedResource(R.drawable.albumart_unknown, album, position));
                BitmapDrawable drawable = (BitmapDrawable) holder.cover
                        .getDrawable();
                drawable.setAntiAlias(true);
                Log.v("AlbumAdapter", "Missing cover... adding default");
            } else {
                holder.cover.setLayoutParams(new Gallery.LayoutParams(120,
                        170));
                holder.cover
                        .setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                holder.cover
                        .setImageDrawable(coverImages.get(position));
                BitmapDrawable drawable = (BitmapDrawable) holder.cover
                        .getDrawable();
                drawable.setAntiAlias(true);
                Log.v("AlbumAdapter", "adding artist cover...");
            }
        }
        return convertView;
    }
</code></pre>

<p>Here is the log:</p>

<pre><code>08-02 01:10:46.821: VERBOSE/Album:(562): Adding Alice In Chains Alice In Chains
</code></pre>

<p>08-02 01:10:46.821: VERBOSE/Album:(562): Adding Alice In Chains Black Gives Way To Blue
08-02 01:10:46.821: VERBOSE/Album:(562): Adding Alter Bridge Blackbird
08-02 01:10:46.831: VERBOSE/Album:(562): Adding Alice In Chains Dirt
08-02 01:10:46.831: VERBOSE/Album:(562): Adding Alice In Chains Facelift
08-02 01:10:46.831: VERBOSE/Album:(562): Adding Alice In Chains Jar Of Flies
08-02 01:10:46.831: VERBOSE/Album:(562): Adding August Burns Red Messengers
08-02 01:10:46.831: VERBOSE/Album:(562): Adding As I Lay Dying An Ocean Between Us
08-02 01:10:46.831: VERBOSE/Album:(562): Adding Alter Bridge One Day Remains
08-02 01:10:46.842: VERBOSE/Album:(562): Adding Alice In Chains SAP
08-02 01:10:46.852: VERBOSE/Album:(562): Adding As I Lay Dying Shadows Are Security
08-02 01:10:46.852: VERBOSE/Album:(562): Adding August Burns Red Thrill Seeker
08-02 01:10:46.852: VERBOSE/Album:(562): Adding Alice In Chains Unplugged
08-02 01:10:46.871: VERBOSE/Log(562): got here</p>

<p>08-02 01:10:49.311: VERBOSE/coverImageAdapter(562): Count is: 13</p>

<p>08-02 01:10:49.321: VERBOSE/Gallery(562): Object: android.widget.Gallery@439558c0 Child count: 0</p>

<p>08-02 01:10:49.571: INFO/ActivityManager(222): Displayed activity com.androidworkz.andamp/.andAMP: 4062 ms (total 4062 ms)</p>
