如何划分横向经理

时间:2012-04-21 03:46:44

标签: java blackberry calendar

enter image description here我试图在一个水平管理器中显示事件,我有多个事件说现在我有10个事件,我想要显示两个事件单行,创建5个水平管理器显示其余10个events。我可以使用下面的代码段在一行中显示一个事件,如何编辑下面的代码片段以在一行中获取两个事件,此处事件被添加到labelfield。

VerticalFieldManager vfm = new VerticalFieldManager();
        int allDayVectorSize = allDayVector.size();
        horizontalFieldManager_isAllDay = new HorizontalFieldManager[allDayVectorSize];
        allDayLabel = new LabelField[allDayVectorSize];
        row_height = 90;
        int j = 0;
        int row_count = 0;

        if (allDayVectorSize != 0) {
            for (int i = 0; i < allDayVectorSize; i++) {
                final String allEvent = (String) allDayVector.elementAt(i);
                horizontalFieldManager_isAllDay[row_count] = new HorizontalFieldManager(
                        Manager.FOCUSABLE | Manager.HORIZONTAL_SCROLL) {

                    protected boolean navigationClick(int status, int time) {
                        Field field = getFieldWithFocus();

                        Vector data = getData(listEvent);

                        if (allEvent != null && allEvent != "") {
                            System.out.println("Currentdata in if" + allEvent);
                            UiApplication.getUiApplication().pushScreen(
                                    new EventScreen(data, allEvent, ""));
                        }
                        return super.navigationClick(status, time);
                    }

                    protected boolean keyChar(char key, int status, int time) {
                        Field field = getFieldWithFocus();

                        return super.keyChar(key, status, time);
                    }

                    protected void sublayout(int maxWidth, int maxHeight) {
                        int displayWidth = Display.getWidth();
                        int displayHeight = 30;
                        super.sublayout(displayWidth, displayHeight);
                        setExtent(displayWidth, displayHeight);
                    }
                };
                horizontalFieldManager_isAllDay[row_count].setPadding(2, 2, 2,
                        2);
                allDayLabel[row_count] = new LabelField(allEvent,
                        LabelField.FOCUSABLE) {

                    protected void layout(int maxWidth, int maxHeight) {

                        int displayWidth = (int) (Display.getWidth() / 2);
                        int displayHeight = maxHeight;

                        super.layout(displayWidth, displayHeight);
                        setExtent(displayWidth, displayHeight);
                    }

                };

                // allDayLabel[row_count].setPadding(5, 0, 0, 2);
                final ImageButtonField alarmBitmapField2 = new ImageButtonField(
                        "", Field.FOCUSABLE, "ringtone.png", "ringtone.png",
                        0x9cbe95);
                horizontalFieldManager_isAllDay[row_count]
                        .add(alarmBitmapField2);
                horizontalFieldManager_isAllDay[row_count]
                        .add(allDayLabel[row_count]);
                vfm.add(horizontalFieldManager_isAllDay[row_count]);
                vfm.add(new SeparatorField());
            }
        }

1 个答案:

答案 0 :(得分:0)

VerticalFieldManager vfm = new VerticalFieldManager();
        int allDayVectorSize = allDayVector.size();
        int hfmSize=(allDayVectorSize %2 ==0)allDayVectorSize/2:allDayVectorSize +1;
        horizontalFieldManager_isAllDay = new HorizontalFieldManager[hfmSize];
        allDayLabel = new LabelField[allDayVectorSize];
        row_height = 90;
        int j = 0;

        if (allDayVectorSize != 0) {
            for (int i = 0; i < hfmSize; i++) {

                horizontalFieldManager_isAllDay[i] = new HorizontalFieldManager(
                        Manager.FOCUSABLE | Manager.HORIZONTAL_SCROLL|Manager.USE_ALL_WIDTH) {

                    protected boolean navigationClick(int status, int time) {
                        Field field = getFieldWithFocus();

                        Vector data = getData(listEvent);

                        if (allEvent != null && allEvent != "") {
                            System.out.println("Currentdata in if" + allEvent);
                            UiApplication.getUiApplication().pushScreen(
                                    new EventScreen(data, allEvent, ""));
                        }
                        return super.navigationClick(status, time);
                    }

                    protected boolean keyChar(char key, int status, int time) {
                        Field field = getFieldWithFocus();

                        return super.keyChar(key, status, time);
                    }

                    protected void sublayout(int maxWidth, int maxHeight) {
                        int displayWidth = Display.getWidth();
                        int displayHeight = 30;
                        super.sublayout(displayWidth, displayHeight);
                        setExtent(displayWidth, displayHeight);
                    }
                };
                horizontalFieldManager_isAllDay[i].setPadding(2, 2, 2,
                        2);
                String allEvent = (String) allDayVector.elementAt(i*2);
                allDayLabel[i*2] = new LabelField(allEvent,
                        LabelField.FOCUSABLE) {

                    protected void layout(int maxWidth, int maxHeight) {

                        int displayWidth = (int) (Display.getWidth() / 2);
                        int displayHeight = maxHeight;

                        super.layout(displayWidth, displayHeight);
                        setExtent(displayWidth, displayHeight);
                    }

                };



                // allDayLabel[row_count].setPadding(5, 0, 0, 2);
                final ImageButtonField alarmBitmapField2 = new ImageButtonField(
                        "", Field.FOCUSABLE, "ringtone.png", "ringtone.png",
                        0x9cbe95);
                horizontalFieldManager_isAllDay[i]
                        .add(alarmBitmapField2);
                horizontalFieldManager_isAllDay[i]
                        .add(allDayLabel[i*2]);
                if(i*2+1<allDayVectorSize)
                {
                       allEvent = (String) allDayVector.elementAt(i*2+1);
                       allDayLabel[i*2] = new LabelField(allEvent,
                       LabelField.FOCUSABLE) {

                              protected void layout(int maxWidth, int maxHeight) {

                                  int displayWidth = (int) (Display.getWidth() / 2);
                                  int displayHeight = maxHeight;

                                  super.layout(displayWidth, displayHeight);
                                  setExtent(displayWidth, displayHeight);
                             }

                         };

                         horizontalFieldManager_isAllDay[i]
                        .add(allDayLabel[i*2+1]);
                   }
                vfm.add(horizontalFieldManager_isAllDay[row_count]);
                vfm.add(new SeparatorField());
            }
        }