Blackberry UI指南,用于制作像iPhone一样的工具栏

时间:2012-05-03 19:24:10

标签: blackberry custom-controls usability

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

enter image description here

在完成googleing之后,我遇到了下面列出的几件事

  1. 使用菜单项和放置图标
  2. 创建与iPhone相同的ToolBar,但是从SDK SDK 6.0起可以再次使用API​​。我热衷于在BB SDK 5.0中实现。我们可以定制相同但我相信这将是一项巨大的努力。
  3. 一些参考链接

    BlackBerry - Custom menu toolbar

    how to create iphone like tabs layout in blackberry

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

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

2 个答案:

答案 0 :(得分:2)

您可以使用Advanced UI components,我们在项目中使用它们,他们通常会这样做。

代码是开源的,如果需要,可以扩展它们。

答案 1 :(得分: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;
    }
}

}