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 );
}
}