1

我想在黑莓中制作一个现有的 iPhone 应用程序。现在我正处于模型设计的可行性研究阶段。我正在寻找为黑莓实现 iPhone 工具栏(如下图所示)的功能。我并不是真的想实现相同的,它可以根据黑莓 UI 指南进行更改。

在此处输入图像描述

在进行一轮谷歌搜索后,我遇到了下面列出的几件事

  1. 使用菜单项和放置图标
  2. 创建与 iPhone 相同的 ToolBar,但 API 仍可从 BB SDK 6.0 开始使用。我热衷于在 BB SDK 5.0 中实现。我们可以定制相同的,但我相信这将是一个巨大的努力。

一些参考链接

BlackBerry - 自定义菜单工具栏

如何在黑莓中创建类似 iphone 的标签布局

http://docs.blackberry.com/en/developers/deliverables/17965/Toolbars_6_0_1137042_11.jsp

请在不违反黑莓可用性指南的情况下提出任何其他最佳实施方式,并且可能最适合我的要求。

4

2 回答 2

2

您可以使用高级 UI 组件,我们在项目中使用它们,它们通常可以解决问题。

该代码是开源的,如果需要,您可以对其进行扩展。

于 2012-05-04T06:43:41.443 回答
1

尝试这个 -

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class tabbar extends UiApplication {

public tabbar() {
    TabControlScreen screen = new TabControlScreen();
    pushScreen(screen);
}

/**
 * @param args
 */
public static void main(String[] args) {
    tabbar app = new tabbar();
    app.enterEventDispatcher();
}

private class TabControlScreen extends MainScreen implements FocusChangeListener {



    private VerticalFieldManager tabArea;

    private LabelField tab1Heading;
    private LabelField tab2Heading;
    private LabelField tab3Heading;
    private LabelField tab4Heading;


    private VerticalFieldManager tab1Manager;
    private VerticalFieldManager tab2Manager;
    private VerticalFieldManager tab3Manager;
    private VerticalFieldManager tab4Manager;
    BitmapField bit,bit1,bit2,bit3;

    public TabControlScreen() {



        HorizontalFieldManager hManager = new HorizontalFieldManager(FIELD_HCENTER);

        final Bitmap header_logo = Bitmap.getBitmapResource("1.png");
        bit=new BitmapField(header_logo,BitmapField.FOCUSABLE |BitmapField.HIGHLIGHT_FOCUS);

        final Bitmap header_logo1 = Bitmap.getBitmapResource("3.png");
        bit1=new BitmapField(header_logo1,BitmapField.FOCUSABLE |BitmapField.HIGHLIGHT_FOCUS);

        final Bitmap header_logo2 = Bitmap.getBitmapResource("2.png");
        bit2=new BitmapField(header_logo2,BitmapField.FOCUSABLE |BitmapField.HIGHLIGHT_FOCUS);

        final Bitmap header_logo3 = Bitmap.getBitmapResource("4.png");
        bit3=new BitmapField(header_logo3,BitmapField.FOCUSABLE |BitmapField.HIGHLIGHT_FOCUS);


        bit.setFocusListener(this);
        bit1.setFocusListener(this);
        bit2.setFocusListener(this);
        bit3.setFocusListener(this);


        hManager.add(bit);
        hManager.add(bit1);
        hManager.add(bit2);
        hManager.add(bit3);



        add(hManager);

        tab1Manager = new VerticalFieldManager();
        tab2Manager = new VerticalFieldManager();
        tab3Manager = new VerticalFieldManager();
        tab4Manager = new VerticalFieldManager();


        tabArea = displayTab1();
        add(tabArea);

    }

    public void focusChanged(Field field, int eventType) {
        if (tabArea != null) {
            if (eventType == FOCUS_GAINED) {
                if (field == bit) {

                    delete(tabArea);
                    tabArea = displayTab1();
                    add(tabArea);
                } else if (field == bit1) {

                    delete(tabArea);
                    tabArea = displayTab2();
                    add(tabArea);
                } else if (field == bit2) {

                    delete(tabArea);
                    tabArea = displayTab3();
                    add(tabArea);
                }
                else if (field == bit3) {

                    delete(tabArea);
                    tabArea = displayTab4();
                    add(tabArea);
                }
            }
        }

    }

    public VerticalFieldManager displayTab1() {
        if (tab1Heading == null) {
            tab1Heading = new LabelField("1");

            ButtonField settings=new ButtonField("Settings",ButtonField.FIELD_LEFT);
            //ButtonField add=new ButtonField("Add",ButtonField.FIELD_RIGHT);

            //JustifiedHorizontalFieldManager JustifiedHorizontalFieldManager=new JustifiedHorizontalFieldManager(settings,add,true);


            tab1Manager.add(settings);
        }

        return tab1Manager;
    }



    public VerticalFieldManager displayTab2() {
        if (tab2Heading == null) {
            tab2Heading = new LabelField("2");
            tab2Manager.add(tab2Heading);
        }

        return tab2Manager;
    }

    public VerticalFieldManager displayTab3() {
        if (tab3Heading == null) {
            tab3Heading = new LabelField("3");
            tab3Manager.add(tab3Heading);
        }

        return tab3Manager;
    }
    public VerticalFieldManager displayTab4() {
        if (tab4Heading == null) {
            tab4Heading = new LabelField("4");
            tab4Manager.add(tab4Heading);
        }

        return tab4Manager;
    }
}

}
于 2012-05-04T04:42:38.257 回答