Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo

Calling a variable from another class?

Hey guys, its the noobie again. I'm trying to have an editField take a name from the user then when the 'next' button is clicked have that name displayed on the next screen. I have everything worked out except in the next screen the variable is not transferring (its underlining the variable in red saying I have to create it). Please help, thanks. Smiley Very Happy

 

Something like this: (I'm guessing public String is wrong for this?)

 

public class newScrn extends MainScreen{
    public String namePerm;

    newScrn() {

             //code

        }

}

 

 

 

Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Calling a variable from another class?

[ Edited ]

I would pass the name into the new screen :

 

 

public class newScrn extends MainScreen{
 

    newScrn( String namePerm) {

             //code

        }


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Trusted Contributor
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo

Re: Calling a variable from another class?

My problem turned out to be in the first class, I tinkered a while and found it.

 

                    String namePerm = nameField.getText();
                    UiApplication.getUiApplication().popScreen(Ui.getUiEngine().getActiveScreen());
                    UiApplication.getUiApplication().pushScreen(new newGame2(namePerm));

 

Also, does anyone know how to delete a post?

Developer
Posts: 97
Registered: ‎10-06-2009
My Device: Not Specified

Re: Calling a variable from another class?

hii,

 

 

  String namePerm = nameField.getText();

  UiApplication.getUiApplication().pushScreen(new newGame2(namePerm));

  UiApplication.getUiApplication().popScreen(this); //As you r in the same class of the screen which you want to pop

 

This will work for you