BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 07-06-2007, 01:33 PM   #1 (permalink)
Knows Where the Search Button Is
Join Date: May 2007
Model: 8800
Carrier: Rogers
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ListField, Variable Row Height, and OS 4.1

Please Login to Remove!

I'm trying to display a list of Bitmaps. The bitmaps are all different sizes.

When I use the following code in a Blackberry that runs OS 4.2, everything is fine. As soon as I use the following code for OS 4.1 (say an 8700), things are all screwed up.

Anybody have any thoughts?

 * Displays a list of bitmap images
 * Copyright (C) 2007  Albert Huh
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <>.
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ObjectListField;

public class BitmapList extends ObjectListField {

    private static int TOP_BUFFER = 2;
    private static int BOTTOM_BUFFER = 2;

    public void drawListRow( ListField lf, Graphics g, int i, int y, int w ) {
        Bitmap b = (Bitmap) get( lf, i );

        // rowheight is heigh of the image plus a buffer at top and bottom
        int rowHeight = b.getHeight() + TOP_BUFFER + BOTTOM_BUFFER;
        setRowHeight( i, rowHeight );

        // draw the image a bit off top of the row
        g.drawBitmap( 0, y + TOP_BUFFER, b.getWidth(), b.getHeight(), b, 0, 0 );

        //draw seperator line
        g.setColor( Color.DARKGRAY );

        // draw line across bottom of the row
        g.drawLine( 0, y + rowHeight - 1, w, y + rowHeight - 1 );

Old 07-06-2007, 03:28 PM   #2 (permalink)
Talking BlackBerry Encyclopedia
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts

all screwed up like they're wrongly sized or you get compiler or runtime exceptions

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.