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
Regular Contributor
pankaj_pradeep
Posts: 88
Registered: ‎04-09-2010
My Device: 9530
My Carrier: Software Developer

How to create a global tab bar

Hi

 

i am creating a application which is having a global tab bar .bar will have 4 buttonsand  will be seen on every screen. i am not able to find any way , can any one please help me out. its urgent..

 

2241iA05AEDF271AAC324

 

Thanks alot

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to create a global tab bar

Using the current API, there is no way to create a global tab bar in the way you want.  You will have to create this for each screen.

Please use plain text.
Developer
Zeeshan0581
Posts: 86
Registered: ‎01-09-2009
My Device: Not Specified

Re: How to create a global tab bar

I have done something similar in past. 

 

1. Create a class that creates the NAVIGATION BAR on bottom.

2. Create a static class Global

  a.  Create object NAVIGATION BAR in it

  b.  Create a STATE related to each button on the navigation bar(this will be used to draw the highlighted button of current screen.

 

3. Every screen you create, add this to your screen on the bottom of it using Vertical Field Manager

add(Global.NavigationBar)

 

Rest of it, i am sure you can figure it out, unfortunatly i cannot disclose the code.

 

Hope it helps

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to create a global tab bar

I suspect that the method provided by Zeeshan0581 will not work.  The issue is that a Field (or Manager) can only be added to one screen at a time.  So the first add of this Global navigation bar will work, but every add to another screen after that will fail with an IllegalStateException telling you that the Field is already parented.

 

If you want to use this method, you will have to dynamically add and remove this tab bar as Screens are displayed. 

 

While I said this could not be done, of course you can 'simulate' this sort of thing by extending MainScreen, to implement this TabBar, then in your application, each of your screens can extend you MainScreen with tab bar already built in.  Looks like a 'global' tab bar, but is actually just a clone. 

 

 

 

 

Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: How to create a global tab bar

He could have a single bar and just add to a screen when it is pushed on the stack top and remove it when the screen goes off the top of the stack.

 

 

Please use plain text.
Developer
Zeeshan0581
Posts: 86
Registered: ‎01-09-2009
My Device: Not Specified

Re: How to create a global tab bar

peter is correct you will get an exception this way.  I was creating the navigation bar in each screen.  here is what i missed

 

Global class has the following fxn that will create your navigaton bar

 

 public static void drawNavigationBar(MainScreen screen, int setFocusTo)
{

  //create hfm

 //add all buttons in hfm

 

screen.add(hfm);

}

 

at the end of all screens do the follwing:

 

...

 

Global.drawNavigationBar(this, NAV_BAR_EDIT_FOCUS);

 

 

Not sure if its the best way to do what you want, but it worked for me.

 

Please use plain text.
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: How to create a global tab bar

The way i have done this is to use multiple managers instead of multiple screens and just swap the managers in and out as needed.

Please use plain text.
Regular Contributor
dipanwita_dev
Posts: 68
Registered: ‎08-16-2011
My Device: TMOBILE 8900
My Carrier: developer

Re: How to create a global tab bar

i am facing Illegal statement exception.i am using tab area having 4 buttons.but in hompage i have som input to display.in my case, home page is displayed for the first time next time its throwing error.but for other pages i can easily navigate

plz give me solution

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to create a global tab bar

It is impossible for us to give you a solution to this problem with the information supplied.  But no, we do not want your code.  Instead you need to debug this properly.  When the Exception occurs (I presume you can replicate this in the SImulator), you need to drill down and find out the Detail message associated with the Exception you are seeing.  I am suspecting it will be something like 'already parented' or 'focus set when not on screen', which you should figure out easily by yourself.  Even if you can't figure this out, look at the statement in your program that has the problem and figure out what you could have done wrong with that statement.  If you can't figure that out, then post the statement in your program that is causing the problem.  We might be able to help from that. 

Please use plain text.
Regular Contributor
dipanwita_dev
Posts: 68
Registered: ‎08-16-2011
My Device: TMOBILE 8900
My Carrier: developer

Re: How to create a global tab bar

thanks!i got my prob.solved!

Please use plain text.