2011-11-30 67 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

相關問題