1

ブラックベリーカレンダーからイベントを取得しようとしています。同時に発生するイベントを次々と見せようとしています

8:00 e1
8:00 e2

ネイティブカレンダーのように

しかし、次のコードは出力を次のように示しています

8:00 e1 e2

私のコードでは、24個のhfmを単一のvfmに追加しています。

int size1 = 2;
horizontalFieldManager_left22 = new  HorizontalFieldManager[size1];
for (int y = 0; y < size1; y++) {
horizontalFieldManager_left22[y] = new  HorizontalFieldManager() {
protected boolean navigationClick(int status, int time) {
Field field = getFieldWithFocus();
Vector data = getData(listEvent);
String  currentData = desc22.getText();
String  currentTime = time22.getText();
 if  (currentData != null && currentData != "") {
         UiApplication.getUiApplication().pushScreen(new EventScreen(data,currentData,currentTime));
            }
    return super.navigationClick(status, time);
        }

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

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

   int size = eventVector7.size();
   LabelField[] labelField = new
   LabelField[size];
   for (int x = 0; x < eventVector7.size(); x++) {
   labelField[x] = new
   LabelField("", Field.FOCUSABLE);
   String data = (String)
   eventVector7.elementAt(x);
   labelField[x].setText(data);
  horizontalFieldManager_left22[y].add(time22);

  horizontalFieldManager_left22[y].add(min22);

  horizontalFieldManager_left22[y].add(new LabelField(" "));

  horizontalFieldManager_left22[y].add(labelField[x]);

        }

   }
 for (int z = 0; z < size1; z++) {
       vfm.add(horizontalFieldManager_left22 [z]);
       vfm.add(new SeparatorField());
      }
4

1 に答える 1

1
import java.util.Hashtable;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;
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 ListAllEvents extends MainScreen {

// -----------------------------------------------------------------

VerticalFieldManager mainManager;

VerticalFieldManager listVFM;
HorizontalFieldManager rowHFM[];

int row_height;

LabelField[] eventTimeLabel;
LabelField[] eventNameLabel;

public ListAllEvents() {

    createUI();

    createEventHashtable();

}

// -------------- Create UI --------------------------------

public void createUI() {

    mainManager = new VerticalFieldManager(
            VerticalFieldManager.VERTICAL_SCROLL
                    | VerticalFieldManager.VERTICAL_SCROLLBAR
                    | VerticalFieldManager.USE_ALL_HEIGHT
                    | VerticalFieldManager.FIELD_LEFT | DrawStyle.LEFT) {

        protected void sublayout(int maxWidth, int maxHeight) {
            int displayWidth = Display.getWidth();
            int displayHeight = Display.getHeight();

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

        public void paint(Graphics g) {
            g.setBackgroundColor(Color.WHITE);
            g.clear();
            super.paint(g);
        }
    };

    add(mainManager);

}

// ----------------------------Create List
// ----------------------------------------

public void createList(Hashtable eventHashtable) {

    listVFM = new VerticalFieldManager();

    rowHFM = new HorizontalFieldManager[eventHashtable.size()];

    eventTimeLabel = new LabelField[eventHashtable.size()];

    eventNameLabel = new LabelField[eventHashtable.size()];

    row_height = 90;

    int j = 0;
    int row_count = 0;

    if (eventHashtable.size() > 0) {

        EventItem ei = null;

        for (int i = 0; i < eventHashtable.size(); i++) {

            Object obj = eventHashtable.get(new Integer(i));

            final EventItem item = (EventItem) obj;

            if (item != null) {

                String str_event_time = item.event_time;
                String str_event_name = item.event_name;

                rowHFM[row_count] = new HorizontalFieldManager(
                        HorizontalFieldManager.USE_ALL_HEIGHT) {

                    protected void sublayout(int maxWidth, int maxHeight) {

                        int displayWidth = Display.getWidth();
                        int displayHeight = 80;

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

                };

                rowHFM[row_count].setPadding(2, 2, 2, 2);

                eventTimeLabel[row_count] = new LabelField(str_event_time) {

                    protected void layout(int maxWidth, int maxHeight) {

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

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

                };

                eventTimeLabel[row_count].setPadding(5, 0, 0, 2);

                eventNameLabel[row_count] = new LabelField(str_event_name) {

                    protected void layout(int maxWidth, int maxHeight) {

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

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

                };

                eventNameLabel[row_count].setPadding(5, 0, 0, 2);

                rowHFM[row_count].add(eventTimeLabel[row_count]);

                rowHFM[row_count].add(eventNameLabel[row_count]);

                listVFM.add(rowHFM[row_count]);

            }

        }

    }
    listVFM.setPadding(5, 2, 5, 2);

    mainManager.add(listVFM);

}

public void createEventHashtable() {

    String event_time1 = "8:00";
    String event_time2 = "8:00";

    String event_name1 = "Event 1";
    String event_name2 = "Event 2";

    Hashtable eventHashtable = new Hashtable();

    eventHashtable.put(new Integer(0), new EventItem(event_time1,
            event_name1));
    eventHashtable.put(new Integer(1), new EventItem(event_time2,
            event_name2));

    createList(eventHashtable);
}

 }




public class EventItem {

String event_time;
String event_name;

public EventItem(String event_time, String event_name) {
    this.event_name = event_name;
    this.event_time = event_time;
}

 }
于 2012-04-11T11:47:47.027 に答える