views:

83

answers:

2

Hi everyone im having problems in my Blackberry application.................

I have made a simple application it starts with a file called AppStarter

package in.EventTimer;

import net.rim.device.api.ui.UiApplication;

public class AppStarter extends UiApplication
{
    public static void main (String[] args)
    {
        AppStarter theApp = new AppStarter ();
        theApp.enterEventDispatcher ();
    }
    public AppStarter()
    {
        //display a new screen
        pushScreen (new ConnectionSettings ());
    }

}

From this AppStarter file it pushes to the second file which is a Screen for the ConnectionSettings

package in.EventTimer;

import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;




public class ConnectionSettings extends MainScreen
{


    public void RadioButton()
    {

    RadioButtonGroup rbg = new RadioButtonGroup();
    RadioButtonField rb1 = new RadioButtonField("tcp");
    RadioButtonField rb2 = new RadioButtonField("gprs");
    RadioButtonField rb3 = new RadioButtonField("wifi");

    rbg.add(rb1);
    rbg.add(rb2);
    rbg.add(rb3);

    }





    public boolean onClose()
    {
        Dialog.alert ("Exit Connection Settings!");
        System.exit (0);
        return true;
    }

}

But when iam running this application in my Blackberry 9700 simulator it is just giving the blank white screen and when im exiting that white screen it is giving the message exitconnection settings which means it is on the connection settings screen but when i run it is showing blank white screen........i have tried many things but no solution yet ............so plz help or suggest something.

Thanks in advance

+1  A: 

Try adding the following method to the ConnectionSettings class:

public ConnectionSettings()
{
        super();

        LabelField title = new LabelField("HelloWorld Sample",
                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));
}

Looks like you are missing a constructor... For your MainScreen class

So the final code should look like this:

package in.EventTimer;

import net.rim.device.api.ui.component.*; 
import net.rim.device.api.ui.container.MainScreen;

public class ConnectionSettings extends MainScreen {

    public void RadioButton()
    {

            RadioButtonGroup rbg = new RadioButtonGroup();
            RadioButtonField rb1 = new RadioButtonField("tcp");
            RadioButtonField rb2 = new RadioButtonField("gprs");
            RadioButtonField rb3 = new RadioButtonField("wifi");

            rbg.add(rb1);
            rbg.add(rb2);
            rbg.add(rb3);

            add(rb1);  //Added by eSniff
            add(rb2);  //Added by eSniff
            add(rb3);  //Added by eSniff

    }

    //Begin added by eSniff
    public ConnectionSettings() 
    {
        super();

        LabelField title = new LabelField("APP STARTER",
            LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));

        RadioButton();
    }
    //End added by eSniff


    public boolean onClose()
    {
        Dialog.alert ("Exit Connection Settings!");
        System.exit (0);
        return true;
    }
}
eSniff
Tried that also but the same problem it is giving the msgRadioButton() method not invoked is there any other way to solve this problem
saif
The lack of the constructor was the largest issue and I tested the above and I do not get a blank screen, but yes the RadioButtons are missing. Because A your not calling the method RadioButton and B the method isn't adding the radioButtons to the screen.. I will edit the above code so that it also adds the RadioButtons to the screen. Good luck on your project.:-)
eSniff
A: 
  1. Make the variable "rgb" into a class field
  2. Define a constructor.
  3. In that constructor, you must first call the function RadioButtons(), then call add(rgb) in your constructor, you must first call RadioButtons(), then invoke add(rgb) to ensure that your fields show up on screen.
Marc Paradise