2012-07-14 42 views
0

我是黑莓開發的新手。我試圖把文本放在按鈕上,但它根本不工作。應該有一個簡單的解決方案,但我無法找到它。這裏的代碼即時通訊使用如何在buttonField上顯示文本標籤黑莓

public class ProgramListView extends VerticalFieldManager{ 

    private int _height; 
    private int _xPos; 

    private ButtonField evaluateButton; 

    //height is used to define each item height 
    //xPos is used to define each items position on screen 
    public ProgramListView(int height, int xPos){ 
     this._height = height; 
     this._xPos = xPos; 

     evaluateButton = new ButtonField("Evaluate", ButtonField.CONSUME_CLICK){ 

      //put methods in here to change the button's position 
     }; 
     super.add(evaluateButton); 
    } 

在此先感謝。

+0

我想方法你有覆蓋佈局和油漆導致問題顯示你的按鈕文本PLZ刪除這些重寫的功能,並讓我knw它工作與否?謝謝 – SALMAN 2012-07-14 09:56:58

+0

如果您只是要調用同一方法的超類版本,而無需修改參數或任何其他工作,則沒有必要重寫方法(例如'layout()'和'paint()')。看到一個[Java方法在這裏覆蓋教程](http://www.tutorialspoint.com/java/java_overriding.htm) – Nate 2012-07-14 10:48:48

+0

我已經刪除了方法,但仍然沒有標籤。這些方法將被用於後來把按鈕放在正確的地方 – madcoderz 2012-07-14 10:51:47

回答

1
ButtonField btnPreviewTone; 
btnPreviewTone = new ButtonField(ButtonField.HIGHLIGHT_SELECT |  ButtonField.CONSUME_CLICK); 
btnPreviewTone.setLabel("Preview Ringtone"); 

我這樣做,它爲我工作。謝謝

+0

我測試了和沒有方法,它沒有爲我工作... – madcoderz 2012-07-14 10:12:01

+0

這個答案並沒有真正清楚爲什麼你通過兩個不同的字符串到' ButtonField'。一些澄清將使這個更好的答案。 – Nate 2012-07-14 20:56:16

+0

這是否適合你? – SALMAN 2012-07-14 22:08:54

0

現在問題已解決。解決方案很明顯。當我將按鈕放在自定義VerticalFieldManager上時,在VerticalFieldManager的sublayout方法中,我必須將其中的參數更改爲Display.USE_ALL_WIDTH。這解決了問題謝謝你的幫助。