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: 154
Registered: ‎02-15-2011
My Device: Not Specified
Accepted Solution

Add layout manager to top of screen (set as banner)

 

Hi,

 

Im trying to set two labels with a background image as screen banner.

Can I set a layout manager as a screen banner ?

 

This code throws an IllegalStateException -

            TableLayoutManager timerBtnManager= new TableLayoutManager
            (new int[]{TableLayoutManager.SPLIT_REMAINING_WIDTH,
                    TableLayoutManager.SPLIT_REMAINING_WIDTH},
                    TableLayoutManager.FIELD_LEFT, true);

            timerBtnManager.add(currentQuestionNumberLabelField);
            timerBtnManager.add(timerLabel);

            add(timerBtnManager);
            setBanner(timerBtnManager);

 

 

Thanks

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

Re: Add layout manager to top of screen (set as banner)

yes, you can use a layout manager in the banner area.

 

check the detail message of the exception, most likely it will give you a hint.

----------------------------------------------------------
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: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Add layout manager to top of screen (set as banner)

 


adrianeireyahoo wrote:

 

Hi,

 

Im trying to set two labels with a background image as screen banner.

Can I set a layout manager as a screen banner ?

 

This code throws an IllegalStateException -

            TableLayoutManager timerBtnManager= new TableLayoutManager
            (new int[]{TableLayoutManager.SPLIT_REMAINING_WIDTH,
                    TableLayoutManager.SPLIT_REMAINING_WIDTH},
                    TableLayoutManager.FIELD_LEFT, true);

            timerBtnManager.add(currentQuestionNumberLabelField);
            timerBtnManager.add(timerLabel);

            add(timerBtnManager);
            setBanner(timerBtnManager);

 

 

Thanks


See the code highlighted in red? This is your problem. I bet your IllegalStateException says something about a field "already parented". Don't add your manager to the screen at all - setting it as Banner adds it to the MainScreen's hidden banner manager. So remove the highlighted code and you should be fine.

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!