0

I wrote a simple program that adds two edit fields to the field manager:

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

But when i run the emulator it is displaying only UserName field only. I am unable to find the other edit field. Why is this problem occuring. I also faced the similar problem while adding checkbox, labelField. Please help me on using this FieldManager. Thank you

Pramod
  • 1,411
  • 11
  • 35
  • 66

2 Answers2

1

Check How to - Implement advanced buttons, fields, and managers.

There is JustifiedHorizontalFieldManager - it should solve your need.

Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91
  • +1, @user609282 what's happening here is the first EditField is using up all the available space so you have no room for the 2nd field. You could override the width to something static in the SubLayout of the EditField but it's a neater solution to use the advanced UI pack like this answer suggests. – Ray Vahey Oct 11 '11 at 08:56
-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);
Himanshu Dudhat
  • 1,609
  • 3
  • 14
  • 27