【问题标题】:Reduce height and width of BlackBerry BasicEditField减小 BlackBerry BasicEditField 的高度和宽度
【发布时间】:2012-09-16 11:23:23
【问题描述】:

我正在尝试更改 BlackBerry BasicEditField 的宽度和高度。 但它没有像我提到的那样显示 BasicEditField。

  HorizontalFieldManager HFMreg = 
      new HorizontalFieldManager(
           HorizontalFieldManager.USE_ALL_WIDTH 
         | HorizontalFieldManager.USE_ALL_HEIGHT) {
      //Override the paint method to draw the background image.
      public void paint(Graphics graphics) { 
          //Draw the registration background image
          graphics.drawBitmap(0,0,Display.getWidth(),Display.getHeight(),BMregbg, 0, 0);
          super.paint(graphics);
      }
  };

  BEFfirstname = new BasicEditField("","",5,EditField.NO_NEWLINE) {
      protected void paint(Graphics graphics) {
          graphics.fillRect(0,0,80,25);
          graphics.setBackgroundColor(Color.WHITE);
          graphics.clear();
          super.paint(graphics); 
      }

      protected void layout() {
          super.layout(getPreferredWidth(),getPreferredHeight());
          setExtent(80,25); //width,height
      }

      public int getPreferredWidth() {
          int fieldWidth = 80; //required width
          return fieldWidth;
      }

      public int getPreferredHeight() {
          int fieldHeight = 25; // required height
          return fieldHeight;
      }
  };
  //BEFfirstname.setMargin(200,0,0,60);

  HFMreg.add(LFfirstname);
  HFMreg.add(BEFfirstname);

  add(HFMreg);

【问题讨论】:

  • 您说“它没有像我提到的那样显示 BasicEditField” - 如果您可以包含屏幕截图或描述输出的问题,将会很有帮助。 “不显示”很模糊

标签: blackberry height width


【解决方案1】:

反过来说:

BasicEditField BEFfirstname = new BasicEditField("","",5,EditField.NO_NEWLINE);
 MyManager obj = new MyManger();
 obj.add(BEFfirstname);
 add(obj);




class MyManager extends Manager
     {
       MyManager()
        {
           super(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT);
         }

        protected void sublayout(int width, int height)
        {
            Field f = getField(0);
              layoutChild(f,80,25);
              setPositionChild(f, 10, 10);      
        }
     }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-24
    • 2016-07-12
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    相关资源
    最近更新 更多