我写了一个简单的程序,它将两个编辑字段添加到字段管理器:
HorizontalFieldManager hrfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
EditField editField1 = new EditField();
editField1.setText("User Name:");
EditField editField2 = new EditField();
editField2.setText("Hello");
hrfm.add(editField1);
hrfm.add(editField2);
add(hrfm);
HorizontalFieldManager hrfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
EditField editField1 = new EditField();
editField1.setText("User Name:");
EditField editField2 = new EditField();
editField2.setText("Hello");
hrfm.add(editField1);
hrfm.add(editField2);
add(hrfm);
但是当我运行模拟器时,它只显示UserName字段。我无法找到其他编辑字段。为什么会出现这个问题。添加复选框labelField时,我也遇到了类似的问题。请帮我使用这个FieldManager。谢谢
答案 0 :(得分:1)
检查How to - Implement advanced buttons, fields, and managers。
有JustifiedHorizontalFieldManager
- 它应该可以解决您的需求。
答案 1 :(得分:-1)
Hope this will helps you.
EditField editField1 = new EditField();
editField1.setText("User Name:");
EditField editField2 = new EditField();
editField2.setText("Hello");
int Width = editField1.getPrefferedWidth()+editField2.getPrefferedWidth();
int Height = editField1.getPrefferedHeight()+editField2.getPrefferedHeight();
HorizontalFieldManager hrfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL)
{
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(Width, Height);
super.setExtent(Width, Height)
}
}
hrfm.add(editField1);
hrfm.add(editField2);
add(hrfm);