在Blackberry上右对齐复选框 [英] Align checkbox to the right on Blackberry

查看:133
本文介绍了在Blackberry上右对齐复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将CheckboxField对齐到固定文本的右侧(在Blackberry上),如管理连接对话框。
代码是:

  final Horizo​​ntalFieldManager hfm = new Horizo​​ntalFieldManager(USE_ALL_WIDTH); 
hfm.add(new LabelField(Test me please,LabelField.ELLIPSIS | FIELD_LEFT | FIELD_VCENTER | USE_ALL_WIDTH));
cbx = new CheckboxField(null,false,FIELD_RIGHT | CheckboxField.NO_USE_ALL_WIDTH);
hfm.add(cbx);

我尝试了USE_ALL_WIDTH,NO_USE_ALL_WIDTH和类似标志的各种组合, t得到我想要的:文本一路向左,并且复选框一直到右边。
如果标签设置为USE_ALL_WIDTH,则复选框将消失,如果未设置,则复选框将显示在文本附近(不在hfm的右侧)。

 使用以下代码解决方案:Horizo​​ntalFieldManager hfm = new Horizo​​ntalFieldManager(Field.USE_ALL_HEIGHT); 
LabelField lblShow = new LabelField(Test me please,Field.FIELD_LEFT);
CheckboxField cbShow = new CheckboxField(,false,CheckboxField.FIELD_RIGHT);
VerticalFieldManager vfmLeft = new VerticalFieldManager();
VerticalFieldManager vfmRight = new VerticalFieldManager(Field.USE_ALL_WIDTH);
vfmLeft.add(lblShow);
vfmRight.add(cbShow);
hfm.add(vfmLeft);
hfm.add(vfmRight);
add(hfm);


I need to align a CheckboxField to the right of a fixed text (on Blackberry) like the "manage connections" dialog. The code is:

final HorizontalFieldManager hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
hfm.add(new LabelField("Test me please", LabelField.ELLIPSIS | FIELD_LEFT | FIELD_VCENTER | USE_ALL_WIDTH));
cbx = new CheckboxField(null, false, FIELD_RIGHT | CheckboxField.NO_USE_ALL_WIDTH);
hfm.add(cbx);

I tried various combinations of "USE_ALL_WIDTH", "NO_USE_ALL_WIDTH" and similar flags, but I still can't get what I want: text all the way to the left, and check box all the way to the right. If the label is set to USE_ALL_WIDTH, the checkbox disappears, and if it's not set, the checkbox is displayed near the text (not on the right side of the hfm).

解决方案

Use following code,this will solve your problem.

HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_HEIGHT);
LabelField lblShow = new LabelField("Test me please ", Field.FIELD_LEFT);
CheckboxField cbShow = new CheckboxField("", false, CheckboxField.FIELD_RIGHT );
VerticalFieldManager vfmLeft = new VerticalFieldManager();
VerticalFieldManager vfmRight = new VerticalFieldManager(Field.USE_ALL_WIDTH); 
vfmLeft.add(lblShow);
vfmRight.add(cbShow);       
hfm.add(vfmLeft);
hfm.add(vfmRight);
add(hfm);

这篇关于在Blackberry上右对齐复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆