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
Developer
Posts: 32
Registered: ‎03-11-2014
My Device: 8520
My Carrier: 8520
Accepted Solution

Back button

[ Edited ]

Hy huys, I'm making an app that allows a user to log in and after it's logged in it shows the username.

Here is the code that display the username when the user is logged in:

 

public LoginSuccessScreen(String username, String selectedDomain) {
        add(new LabelField("Looged in!"));
        add(new LabelField("Username: " + username));
       

 

I made a button called Back that sends me to the previous screen, but it does not show the username anymore

 Here is my back button:

ButtonField back = new ButtonField("Back", ButtonField.CONSUME_CLICK);
        back.setChangeListener(new FieldChangeListener() {
            
            public void fieldChanged(Field field, int context) {
                UiApplication.getUiApplication().pushScreen( new LoginSuccessScreen(null));
                
            }
        });

 

I know that the problem is that i put null in the LogginSuccessScreen, but if i let it emty it shows an error.

Can somebody tell me what to put there to show the username when I push the back button or al least  is this the correct way to make a button that sends you to the previous screen?

Thanks in advance

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

Re: Back button

usually you use a stack of screens. if you go back you just pop the uppermost and the next below is displayed.

if you want to display the LoginSuccessScreen you will have to give it the parameters it wants. Maybe you can store them somewhere and add them in the fieldChanged method?
----------------------------------------------------------
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
Developer
Posts: 32
Registered: ‎03-11-2014
My Device: 8520
My Carrier: 8520

Re: Back button

Thanks, I know what I have to do now Smiley Happy