2011-11-30 65 views
-2

我现在在黑莓中使用ObjectChoiceField。我有字符串数组中的项目,如“a”,“abc”,“abcdefg”等。应用程序根据选择项目的宽度自动设置宽度。我希望ChoiceField中的下拉窗口具有可以容纳字符串数组中最大条目的静态宽度。如何在对象选择字段中设置DropDown窗口的宽度?定制

我的问题是,我可以设置下拉窗口的大小?如果是的话,我怎么能设置DropDown窗口的宽度(它显示您所选择的领域的所有选项)?

+0

你到底在做了.... 你阙和你的答案都是错的... –

+0

@BBExpert:对不起朋友,我是新来这个环境。我想设计,它使用其布局的宽度正好一半大小一个choicefield ..即使我得到它的工作对我来说..再次plz把正确的代码..这将是有用的像我这样的人.. 感谢您的回复 –

回答

-1

我创造了一个自定义选择场..

import net.rim.device.api.ui.component.ObjectChoiceField; 

/* 
* The MyChoiceField is actually an extended class of ObjectChoiceField. 
* In this, the design of an ObjectChoiceField is overloaded with providing some additional 
* tasks is done. It includes a constructor and a Layout methods. 
* In that Layout method the design for the ObjectChoiceField is overrided... 
*/ 
public class MyChoiceField extends ObjectChoiceField 
{ 

    public MyChoiceField(String label ,Object[] choices) 
    { 
     super(label, choices); 
    } 


    protected void layout(int width, int height) 
    { 
     setMinimalWidth(width/2-62); 
     super.layout(width, height); 
    } 

} 

现在我知道了......

感谢....

1

你的问题不明确。在当前的实现中,下拉大小是最大元素的大小。 enter image description here

我的猜测是你想要的“强调”大小元素之后的选择是最大的元素的大小? Larger size of highlighted element

这里,它是小

Smaller size of highlighted element

澄清你打算做什么?

+0

感谢您的帮助第一。 actaually我想设置我的下拉菜单项的大小最大。现在我已经通过扩展objectchoice字段创建了自己的选择字段。 [链接] http://www.enscand.com/roller/enscand/entry/custom_fancy_er_choicefield_for和http://supportforums.blackberry.com/t5/Java-Development/Custom-objectChoiceField-doesn-t-display-selected-choice - 开/ TD-p/196606和http://supportforums.blackberry.com/t5/Java-Development/How-to-Fixed-a-Width-of-ObjectChoiceField/td-p/538079有一些很好的参考... ...它非常帮助我。谢谢 –

+0

为此,您可以创建一个自定义。可以用指定的固定宽度创建我们自己的ChoiceField。 – alishaik786

相关问题