2012-09-15 52 views
1

我已將一個buttonField添加到Blackberry應用程序的Horizo​​ntalFieldManager中。添加EditField後添加了它。然而buttonField不會出現。 下面是我的代碼ButtonField不會出現在Horizo​​ntalFieldManager中

HorizontalFieldManager hfm = new HorizontlFieldManager(); 
    BasicEditField edit = new BasicEditField("Label", "UP"); 
    ButtonField button = new ButtonField("Search"); 
    hfm.add(edit); 
    hfm.add(button); 
    add(hfm); 

回答

2

這個答案並不能解決你的問題,但重要的是要注意你的代碼絕對是好的,而且沒有什麼問題。

HorizontalFieldManager該類充滿了OS 5.0中引入的錯誤,至今爲止(最新版本爲7.x)RIM已表明無意修復它。

作爲示例,here's a bug issue在BB Developer Issue Tracker中仍然未解決。我不得不在最近的項目中處理hfm,並且遇到了一些問題,我必須通過創建自己的經理來解決問題,與Shashank's answer所示的方式類似。您可以在SO中找到更多關於創建自定義管理器的示例。基本知識還包括here

這是目前唯一的解決辦法,因爲RIM正在向BB 10(C++),並將它們傾倒的Java API,所以不要指望他們很快修復它。即使它們是,它也不會被修復,而是在最新的操作系統版本上,因爲BB設備很少被升級,所以這是毫無用處的。

-1

採取VerticalFieldManager insted的HorizantalFieldManager

+0

我想在editfield旁邊添加buttonfield,而不是在 –

+0

ONCE TRY THIS .....在某種程度上限制文字記錄器,如EditField editField = new EditField(「」,「」,10,EditField.EDITABLE ); –

2

您需要設置EditField中寬度&按鈕寬度

protected void layout(int width,int height) 
{ 
super.layout(Display.getWidth() * 3 /4 , getpreferedHeight()); 
super.setExtent(Display.getWidth() * 3/4 , getpreferedHeight()); 
} 

對於按鈕使用

protected void layout(int width,int height) 
{ 
super.layout(Display.getWidth() /4 , getpreferedHeight()); 
super.setExtent(Display.getWidth() /4 , getpreferedHeight()); 
} 
相關問題