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
Highlighted
Regular Contributor
Posts: 61
Registered: ‎03-28-2010
My Device: Bold 9700
My Carrier: Maxis Malaysia
Accepted Solution

Reload function from mainscreen

Here is what I'm trying to accomplish

 

1. Run mainscreen, but do some setup checking.

1. Test issit 1st time running thru

        persistentObject = PersistentStore.getPersistentObject(KEY);
        if (persistentObject.getContents() == null) { // run welcome screen }

2. If yes, run welcome screen instead of mainscreen. Next screen is setup screen.

3. setupscreen.close, save all settings.

4. return to 1.

 

Here is my problem : when setupscreen.close (this.close()), it goes back to welcome screen instead of mainscreen.

 

I tried invalidate(), but to no avail.

 

My skaleton is something like this :

 

This is base

 

 

package net.test.my;

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

public class ptApplication extends UiApplication {

	public ptApplication() {
		ptMainScreen mainScreen = new ptMainScreen();
		pushScreen(mainScreen);
	}

	public static void main(String[] args) {
		ptApplication app = new ptApplication();
		app.enterEventDispatcher();
	}
}

this is Mainscreen

 

package net.test.my;
// imports stuff

public class ptMainScreen extends MainScreen implements FieldChangeListener {

// var declarations

	public ptMainScreen() {

		persistentObject = PersistentStore.getPersistentObject(KEY);
		if (persistentObject.getContents() == null) {
               //Welcome screen with "Setup" button			
               //call to ptSetupScreen via userSettings
 } else { //display real mainscreen } }
private void userSettings() {
        ptSetupScreen setupScreen = new ptSetupScreen();
        UiApplication.getUiApplication().pushScreen(setupScreen);
    }

// fieldChanged and stuffs

 

ptSetupScreen

 

 

package net.test.my;

// import stuffs 

public class ptSetupScreen extends MainScreen implements FieldChangeListener {
	public ptSetupScreen() {
              // setup screen
              // save data then this.close
	}
}

 

 

 

 

 

 

 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Reload function from mainscreen

i would suggest you push the mainscreen first, and the welcome screen on top of it. pop the welcome screen when you push the settings screen.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 61
Registered: ‎03-28-2010
My Device: Bold 9700
My Carrier: Maxis Malaysia

Re: Reload function from mainscreen

Ok, make sense. How should I do that?

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Reload function from mainscreen

using a sophisticated succession of pushscreen and popscreen methods

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 61
Registered: ‎03-28-2010
My Device: Bold 9700
My Carrier: Maxis Malaysia

Re: Reload function from mainscreen

"sophisticated succession". Sir, do you have any sample code, or point me to the right direction in getting the sample code?

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Reload function from mainscreen

i would suggest you read the developer guide and study some of the samples.

 

pushscreen(mainscreen)

pushscreen(welcomescreen)

 

in welcomescreen, on button, popscreen(welcomescreen) and pushscreen(optionsscreen)

in optionsscreen, popscreen(optionsscreen)

-> visible screen is mainscreen

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 61
Registered: ‎03-28-2010
My Device: Bold 9700
My Carrier: Maxis Malaysia

Re: Reload function from mainscreen

Great!

 

I've, sort of, impliment your suggestion, but with minor weird problem (or is it just me who still learning to understand oop)

 

welcome screen have button :

 

settingButton = new CustomButtonField("Update Settings", Color.WHITE, Color.LIGHTGREY, Color.WHITE, Color.BLACK, 0);
    settingButton.setChangeListener(this);
    HorizontalFieldManager buttonManager = new HorizontalFieldManager(Field.FIELD_HCENTER);
    buttonManager.add(settingButton);
    add(buttonManager);

 

1. pushscreen(mainscreen)

2. pushscreen(welcomescreen)

3. on button, popscreen(welcomescreen)

4. pushscreen(optionscreen)

5. on button, this.close(); (optionscreen)

6. welcomescreen visible. Yay! WAIT settingButton visible on top of mainscreen (but all labelfield gone).

 

how come? Smiley Sad

Regular Contributor
Posts: 61
Registered: ‎03-28-2010
My Device: Bold 9700
My Carrier: Maxis Malaysia

Re: Reload function from mainscreen

Ok, the problem gone already. Don't know what happened. Smiley Tongue