简体   繁体   中英

Blackberry application showing blank screen

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM