2

VerticalFieldManagerゼロ以外のマージンを持つ を生成したいので、を作成してVerticalFieldManagerから、vfm.setMargin(10、10、10、10);を使用します。その後、いくつかのfields(buttonFieldObjectChoiceField)を入力します。

単純すぎるようですね。しかし、奇妙なことが起こります。最後に焦点を合わせ、ObjectChoiceFieldスペースを押して選択を切り替えると、ObjectChoiceField消えました。

どうしてそれができるのでしょうか?ここにデモコードがあります、誰かが親切にバグを見つけますか?

final class HelloWorldScreen extends MainScreen{
  HelloWorldScreen() {
    // just a demo to show the strange thing
    String [] arr = {"a","b"};
    for(int i = 0; i < 10; i++){

        VerticalFieldManager vfm = new VerticalFieldManager(); // Field.USE_ALL_WIDTH
        vfm.setMargin(10, 10, 10, 10);
        ButtonField btn = new ButtonField(String.valueOf(i));
        ObjectChoiceField ch = new ObjectChoiceField(String.valueOf(i), arr);

        vfm.add(btn);
        vfm.add(ch);

        add(vfm);
    }
  }
}

編集:必要なUIマージンのスクリーンショット:

ここに画像の説明を入力してください

4

1 に答える 1

1

変です。

コードを実行しない人のために説明すると、オブジェクト選択フィールドをクリックすると、画面全体が少し垂直方向にスクロールします。各垂直スクロールの後、画面は一番下までスクロールできなくなります。このような操作を何度も繰り返した後、最終的にこの画面の下部の多くにアクセスできなくなりました。

なぜこれが起こっているのかわかりません。(私にはBlackBerryのバグのように見えます)

私が観察したことは、あなたが電話をかけると

    vfm.setMargin(10, 10, 10, 10);

問題は解決します。

使用する回避策を提案できますか

    vfm.setPadding(10, 10, 10, 10);

代わりは?

マージンパディングは同じものではないことを知っています。ただし、完全な UI デザイン (私には見えません) によっては、この場合、10 ピクセルのパディングを設定するだけで、目的の処理を行うのに十分な場合があります。


更新:ご希望の UI のスクリーンショットに基づいて、この回避策で作成することができました。繰り返しますが、それほど多くの作業は必要ありませんが、この追加のコードは私にとってはうまくいきました:

public class BugScreen extends MainScreen {

   private static final int BG_COLOR = Color.LIGHTGRAY;
   private static final int FG_COLOR = Color.WHITE;
   private static final int BORDER_LINE_COLOR = Color.GRAY;
   private static final int PAD = 10;

   public BugScreen() {
      super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);

      getMainManager().setBackground(BackgroundFactory.createSolidBackground(BG_COLOR));
      // this additional call ensures that when scrolling bounces, the area "behind"
      // the normal visible area is ALSO of BG_COLOR
      setBackground(BackgroundFactory.createSolidBackground(BG_COLOR));

      // this will establish a thin gray padding on the screen's left/right sides
      // NOTE: I seem to get drawing artifacts if I try to use this for ALL sides!
      getMainManager().setPadding(0, PAD, 0, PAD);

      String [] arr = {"a","b"};
      for(int i = 0; i < 10; i++){

         VerticalFieldManager vfm = new VerticalFieldManager(Field.USE_ALL_WIDTH) {
            public int getPreferredWidth() {
               return Display.getWidth() - 2 * PAD;
            }
            public void paint(Graphics graphics) {
               int oldColor = graphics.getColor();
               super.paint(graphics);
               graphics.setColor(BORDER_LINE_COLOR);
               // draw the (1-pixel wide) border size you would like.
               graphics.drawRect(0, 0, getPreferredWidth(), getHeight());
               graphics.setColor(oldColor);
            }
         };

         vfm.setBackground(BackgroundFactory.createSolidBackground(FG_COLOR));
         ButtonField btn = new ButtonField(String.valueOf(i));
         ObjectChoiceField ch = new ObjectChoiceField(String.valueOf(i), arr);

         vfm.add(btn);
         vfm.add(ch);

         // add a separator field to get thin gray margin between (vfm) fields         
         add(new MarginField());

         add(vfm);
      }

      // add one last margin field at the bottom
      add(new MarginField());
   }

   private class MarginField extends Field {
      public MarginField() {
         super(Field.USE_ALL_WIDTH);
      }
      public int getPreferredHeight() { return PAD; }
      protected void paint(Graphics g) {
         int oldColor = g.getColor();
         g.setColor(BG_COLOR);
         g.fillRect(0, 0, getWidth(), getPreferredHeight());
         g.setColor(oldColor);
      }
      protected void layout(int width, int height) {
         setExtent(width, getPreferredHeight());               
      }     
   }
}
于 2013-02-16T11:53:49.097 に答える