Tuesday, June 22, 2010

Blackberry spacer whitespace generator

I thought android was bad, but Blackberry is 10 times worst. I spent an entire day doing a simple UI. Its not even easy considering the useless API documents. Anyhow I came up with a whitespace method (in place of padding)

private BitmapField whitespace(final int width, final int height) {

Bitmap img = Bitmap.getBitmapResource("transparent.png");
return new BitmapField(img) {
public int getPreferredWidth() {
return width;
}
public int getPreferredHeight() {
return height;
}
protected void layout(int arg0, int height) {
super.layout(getPreferredWidth(), getPreferredHeight());
setExtent(getPreferredWidth(), getPreferredHeight());
}
};
}

No comments: