2012-03-07 6 views
1

수평 현장 관리자의 세 가지 편집 fileds을 생성하는 방법 당신은 올바른 방법으로가는이 enter image description here방법 블랙 베리

HorizontalFieldManager hfm_city=new HorizontalFieldManager(); 
VerticalFieldManager vfm_city = new VerticalFieldManager(); 
vfm_city.setBorder(
        BorderFactory.createBitmapBorder(
        new XYEdges(12,12,12,12), borderBitmap 
         ) 
       ); 
      vfm_city.setMargin(0, 200, 0, 0); 
      final EditField city = new EditField("", "", 30, BasicEditField.FILTER_DEFAULT){ 
              String emptyString = "City"; 
              protected void paintBackground(Graphics g) { 
               g.setBackgroundColor(0xFFFFFF); 
               g.clear(); 
              } 
              protected void paint(Graphics g) { 
               int oldColor = g.getColor(); 
               try { 
                g.setColor(0x000000); 
                test = super.getText(); 
                if (test == null || test.length() < 1) { 
                 //g.setColor(Config.hint_colour); 
                 g.drawText(emptyString, 0, 0); 
                } 
                super.paint(g); 
               } finally { 
                g.setColor(oldColor); 
               } 
              } 
              }; 
              vfm_city.add(city); 




             VerticalFieldManager vfm_state = new VerticalFieldManager(); 
             vfm_state.setBorder(
               BorderFactory.createBitmapBorder(
                new XYEdges(12,12,12,12), borderBitmap 
              ) 
             ); 
             vfm_state.setMargin(0, 0, 0, 0); 
              final EditField state = new EditField("", "", 30, BasicEditField.FILTER_DEFAULT){ 
              String emptyString = "State"; 
              protected void paintBackground(Graphics g) { 
               g.setBackgroundColor(0xFFFFFF); 
               g.clear(); 
              } 
              protected void paint(Graphics g) { 
               int oldColor = g.getColor(); 
               try { 
                g.setColor(0x000000); 
                test = super.getText(); 
                if (test == null || test.length() < 1) { 
                 //g.setColor(Config.hint_colour); 
                 g.drawText(emptyString, 0, 0); 
                } 
                super.paint(g); 
               } finally { 
                g.setColor(oldColor); 
               } 
              } 
              }; 
              vfm_state.add(state); 


              VerticalFieldManager vfm_zip = new VerticalFieldManager(); 
              vfm_zip.setBorder(
                BorderFactory.createBitmapBorder(
                 new XYEdges(12,12,12,12), borderBitmap 
               ) 
              ); 
              vfm_zip.setMargin(0, 0, 0, 0); 
               final EditField zip = new EditField("", "", 30, BasicEditField.FILTER_DEFAULT){ 
               String emptyString = "Zip"; 
               protected void paintBackground(Graphics g) { 
                g.setBackgroundColor(0xFFFFFF); 
                g.clear(); 
               } 
               protected void paint(Graphics g) { 
                int oldColor = g.getColor(); 
                try { 
                 g.setColor(0x000000); 
                 test = super.getText(); 
                 if (test == null || test.length() < 1) { 
                  //g.setColor(Config.hint_colour); 
                  g.drawText(emptyString, 0, 0); 
                 } 
                 super.paint(g); 
                } finally { 
                 g.setColor(oldColor); 
                } 
               } 
               }; 
               vfm_zip.add(zip); 



             hfm_city.add(vfm_city); 
             hfm_city.add(vfm_state); 
             hfm_city.add(vfm_zip); 

답변

1

같은 세 가지 editfields를 만듭니다. 그러나 너비 &의 너비를 VerticalFieldManager에 지정해야합니다. 그렇지 않으면 너비가 기본적으로 적용됩니다.

VerticalFieldManager vfm_city = new VerticalFieldManager() { 
    protected void sublayout(int maxWidth, int maxHeight) { 
     super.sublayout(Display.getwidth()/3,30); 
     setExtent(Display.getwidth()/3,30); 
    } 
}; 

은 국가 & 도시 vfm에서이 작업을 수행하고 hfm에 추가하려고합니다.

0

확인 대답의 나

{ 

     Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID); 


     VerticalFieldManager vert=new VerticalFieldManager() 
     { 
      protected void sublayout(int maxWidth, int maxHeight) { 
       super.sublayout(Display.getWidth(),Display.getHeight()); 
       setExtent(Display.getWidth(),Display.getHeight()); 
      } 

     }; 
      HorizontalFieldManager hr=new HorizontalFieldManager(USE_ALL_HEIGHT) 
      { 
       protected void sublayout(int maxWidth, int maxHeight) { 
        super.sublayout(Display.getWidth(),50); 
        setExtent(Display.getWidth(),50); 
       } 
      }; 
      hr.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN)); 
      EditField e1=new EditField(Field.FOCUSABLE|Field.FIELD_VCENTER){ 

       protected void layout(int width, int height) { 
        super.layout(100,30); 
        setExtent(100,30); 
       } 
      }; 
      EditField e2=new EditField(Field.FOCUSABLE|Field.FIELD_VCENTER){ 

       protected void layout(int width, int height) { 
        super.layout(60,30); 
        setExtent(60,30); 
       } 
      }; 
      EditField e3=new EditField(Field.FOCUSABLE|Field.FIELD_VCENTER){ 

       protected void layout(int width, int height) { 
        super.layout(60,30); 
        setExtent(60,30); 
       } 
      }; 
      e1.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 
      e2.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 
      e3.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 
      e1.setPadding(0, 0, 0, 10); 
      e2.setPadding(0, 0, 0, 20); 
      e3.setPadding(0, 0, 0, 10); 
      e1.setBorder(bdr); 
      e2.setBorder(bdr); 
      e3.setBorder(bdr); 
      hr.add(e1); 

      hr.add(e2); 

      hr.add(e3); 


      vert.add(hr); 
      add(vert); 


    } 

enter image description here