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
PIN: N/A
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?

Code:
/*
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 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 <http://www.gnu.org/licenses/>.
 */
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 );
    }

}
Offline  
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
Default

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


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.