开发者

how to add checkbox, labelField to HorizontalFieldManager

开发者 https://www.devze.com 2023-04-12 07:52 出处:网络
I wrote a simple program that adds two edit fields to the field manager: HorizontalFieldManager hrfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);

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();           
    edit开发者_如何学编程Field1.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


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

There is JustifiedHorizontalFieldManager - it should solve your need.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号