0

my Custom_Field class is like that:

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

The above class is the highlighted in this image

I cannot add BitmapField in the Field class because i want to click the button to go to Main_ParticulatCategoryAllNews class.

Alan Lai
  • 1,094
  • 7
  • 18
  • 41
  • I cannot add BitmapField in the `Field` class because i want to click the button to go to `Main_ParticulatCategoryAllNews` class. - it is unclear. – Rupak Jun 18 '12 at 08:06
  • i had edited the class with added an image – Alan Lai Jun 18 '12 at 08:15
  • You need to change the approach. You can create a HorizontalFieldManager, and on it you can add five ButtonField. Customization of `HorizontalFieldManager` can be done with setting an image background. And instead of `ButtonField` you can implement a `CustomButtonField` with image. – Rupak Jun 18 '12 at 08:21
  • And it is not possible to add any `Field` to an `Field` object. A `Manager` object can add `Field` to it. – Rupak Jun 18 '12 at 08:22
  • if i use built in horizontalFieldManager, then every page need to call it. i want to make it easier that why i create a class then other classes can call it – Alan Lai Jun 18 '12 at 08:38

1 Answers1

0

solved by extends HorizontalFieldManager and using add()

Alan Lai
  • 1,094
  • 7
  • 18
  • 41