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
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Nested class will not add fields to MainScreen

Hello,

 

I am trying to have a nested class access the UI event thread. The code in my nested class will run, but any "add(...)" will not update my MainScreen.

 

Is this not allowed? Thanks!

 

Here is my code:

 

 

public class HomeScreen extends MainScreen implements FieldChangeListener {

     public HomeScreen() {
          doAction();
     }


     public void doAction() {
new InnerClass();
 } class InnerClass extends MainScreen { public InnerClass() { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { add(new SeparatorField()); } }); } } }

 

 

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Nested class will not add fields to MainScreen

Which screen is displayed?

 

Your inner class is adding the field to Innerclass, not HomeScreen.

 

 

 

 

Please use plain text.
Developer
behrk2
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Nested class will not add fields to MainScreen

Ah I see, HomeScreen was being displayed. So what I did was change:

 

 

class MiddleGround extends MainScreen {}

 

 

to:

 

 

class MiddleGround {}

 

and it is working now. Thanks!

 

Please use plain text.