EditField和Buttonfield在同一行上

时间:2012-03-21 09:53:39

标签: blackberry blackberry-editfield

我想在同一行添加editfield和labelfield。首先是editfield,然后是buttonfield。我已经尝试了很多次,但它对我没有用。我添加了水平字段管理器,也使用了表,但没有一个可以帮助。问题是它没有显示buttonfield,我只能看到editfield。 enter code here

 public class MyScreen extends MainScreen {
  /**
    * Creates a new MyScreen object
   */
 public MyScreen()
 {        
     // Set the displayed title of the screen       
     setTitle("MyTitle");



     HorizontalFieldManager m= new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);

     final GridFieldManager   grid  = new GridFieldManager(4,4,0); 

     grid.setColumnPadding(5);
     grid.setRowPadding(5);

     EditField c= new EditField("","",5,EditField.EDITABLE);
  //   m.add(c);
   Border border=BorderFactory.createRoundedBorder(new XYEdges(10,10,10,10),Border.STYLE_SOLID); 




     grid.setBorder(border);
     ButtonField b= new  ButtonField("Select ",ButtonField.CONSUME_CLICK);
     //m.add(b);
     grid.insert(b,1);
     grid.insert(c,0); 
     //add(m);
     add(grid);                          
    } 
 }

2 个答案:

答案 0 :(得分:1)

覆盖getPreferredWidth()EditField的{​​{1}},如下所示:

ButtonField

答案 1 :(得分:0)

覆盖sublayout()&的layout()EditField方法。 ButtonField比设置宽度Ex: 100 ..现在在field添加m.add(); ..它的作品..