0

ここに画像の説明を入力水平マネージャーでイベントを表示しようとしていますが、複数のイベントがあり、今のところ 10 個のイベントがあり、2 つのイベントを 1 行で表示したいので、5 つの水平マネージャーを作成して残りの 10 個のイベントを表示します。以下のスニペットを使用して 1 行にイベントを表示する方法、以下のスニペットを編集して 2 つのイベントを 1 行に表示する方法、ここでイベントがラベル フィールドに追加されます。

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());
            }
        }
4

1 に答える 1

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());
            }
        }
于 2012-04-24T06:07:41.357 に答える