Blackberry 如何在field类中添加bitmapfield或clicklistener?

Blackberry 如何在field类中添加bitmapfield或clicklistener?,blackberry,field,bitmapfield,Blackberry,Field,Bitmapfield,我的自定义\u字段类如下: public class Custom_BottomField extends Field { private Bitmap _backgroundBitmap = Bitmap .getBitmapResource("footer_bar.png"); private Bitmap finance = Bitmap.getBitmapResource("icon_economy.png"), special = Bitmap.ge

我的
自定义\u字段
类如下:

public class Custom_BottomField extends Field {

private Bitmap _backgroundBitmap = Bitmap
        .getBitmapResource("footer_bar.png");

private Bitmap finance = Bitmap.getBitmapResource("icon_economy.png"),
        special = Bitmap.getBitmapResource("icon_title.png"),
        forum = Bitmap.getBitmapResource("icon_forum.png"),
        discussion = Bitmap.getBitmapResource("icon_discussion.png"),
        other = Bitmap.getBitmapResource("icon_other.png");

private BitmapField financebtn, specialbtn, forumbtn, discussionbtn,
        otherbtn;

Custom_BottomField() {
    Background background = BackgroundFactory
            .createBitmapBackground(_backgroundBitmap);
    setBackground(background);
}

protected void layout(int width, int height) {
    width = Math.min(width, getPreferredWidth());
    height = Math.min(height, getPreferredHeight());
    setExtent(width, height);
}

public int getPreferredHeight() {
    return 70;
}

public int getPreferredWidth() {
    return Display.getWidth();
}

protected void paint(Graphics graphics) {
    int rectHeight = getPreferredHeight();
    int rectWidth = getPreferredWidth();
    graphics.drawRect(0, 0, rectWidth, rectHeight);
    graphics.drawBitmap(getGap(), 5, finance.getWidth(),
            finance.getHeight(), finance, 0, 0);
    graphics.drawBitmap(rectWidth / 5 + getGap(), 5, special.getWidth(),
            special.getHeight(), special, 0, 0);
    graphics.drawBitmap(rectWidth * 2 / 5 + getGap(), 5, forum.getWidth(),
            forum.getHeight(), forum, 0, 0);
    graphics.drawBitmap(rectWidth * 3 / 5 + getGap(), 5,
            discussion.getWidth(), discussion.getHeight(), discussion, 0, 0);
    graphics.drawBitmap(rectWidth * 4 / 5 + getGap(), 5, other.getWidth(),
            other.getHeight(), other, 0, 0);
}

private int getGap() {
    return ((getPreferredWidth() / 5) - finance.getWidth()) / 2;
}

private void Button() {
    financebtn = new BitmapField(finance, BitmapField.FOCUSABLE) {
        protected boolean navigationClick(int status, int time) {
            MyApp.getUiApplication().pushScreen(new Main_ParticulatCategoryAllNews());
            return true;
        }
    };
}
}
上面的类是图像中突出显示的类


我无法在
字段
类中添加位图字段,因为我想单击按钮转到
Main\u specificategoryallnews
类。

由extends
HorizontalFieldManager
add()解决

我无法在
字段
类中添加位图字段,因为我想单击按钮转到
Main\u specificategoryallnews
类。-还不清楚。我已经用添加的图片编辑了这个类。你需要改变方法。您可以创建一个HorizontalFieldManager,并在其上添加五个ButtonField。可以通过设置图像背景来定制
HorizontalFieldManager
。您可以使用image实现
CustomButtonField
,而不是
ButtonField
。并且不能将任何
字段
添加到
字段
对象中。
管理器
对象可以向其添加
字段
。如果我使用内置的horizontalFieldManager,那么每个页面都需要调用它。我想让创建一个类比其他类调用它更容易