0

我编写了一个简单的程序,将两个编辑字段添加到字段管理器:

    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);

但是当我运行模拟器时,它只显示用户名字段。我找不到其他编辑字段。为什么会出现这个问题。添加复选框labelField时,我也遇到了类似的问题。请帮助我使用这个 FieldManager。谢谢

4

2 回答 2

1

检查如何 - 实现高级按钮、字段和管理器

JustifiedHorizontalFieldManager-它应该可以解决您的需求。

于 2011-10-11T07:32:31.190 回答
-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);
于 2011-10-11T07:05:04.033 回答