0

Im new to blackberry development. Im trying to put text over a Button but its not working at all. There should be an easy solution but i'm unable to find it. Here's the code im using

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);
    }

Thanks in advance.

madcoderz
  • 4,423
  • 10
  • 47
  • 74
  • I think the method You have override layout and paint is causing problem to show your button text plz remove those overridden functions and thn let me knw is it working or not ? Thanks – SALMAN Jul 14 '12 at 09:56
  • There is no point overriding methods (e.g. `layout()` and `paint()`) if you are just going to call the superclass version of that same method, with no modification of the parameters, or any other work. See a [Java method overriding tutorial here](http://www.tutorialspoint.com/java/java_overriding.htm) – Nate Jul 14 '12 at 10:48
  • i already removed the methods and still the label is not there. Those methods will be used later to put the button on the right place – madcoderz Jul 14 '12 at 10:51

2 Answers2

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

I did this way and it worked for me. Thanks

SALMAN
  • 2,031
  • 1
  • 20
  • 18
  • This answer doesn't really make clear why you pass two different strings in to the `ButtonField`. Some clarification would make this a better answer. – Nate Jul 14 '12 at 20:56
  • Ok now I have edited the code this does make sense to your comment . Thanks – SALMAN Jul 14 '12 at 22:12
  • your solution does not work for me. Im extending VerticalFieldManager maybe thats why it doesnt work? – madcoderz Jul 15 '12 at 11:31
0

The problem is now solved. The solution was obvious. As i put the button on a custom VerticalFieldManager, in the VerticalFieldManager's sublayout method i had to change the parameters in it to Display.USE_ALL_WIDTH. That fixed the problem Thanks for the help.

madcoderz
  • 4,423
  • 10
  • 47
  • 74