我想在同一行添加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);
}
}
答案 0 :(得分:1)
覆盖getPreferredWidth()
和EditField
的{{1}},如下所示:
ButtonField
答案 1 :(得分:0)
覆盖sublayout()
&的layout()
和EditField
方法。 ButtonField
比设置宽度Ex: 100
..现在在field
添加m.add();
..它的作品..