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
TobiasReaper
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

How to delete a Manager or a Field that is currently on Focus?

I've got an application with the following specification:

 

1.The app has a tab bar at the bottom of the screen and a VerticalFieldManager called tabArea as the main content area.

 

2.There are two tabs in the tab bar, tab1 and tab2.


3.When tab1 is pressed on the tab bar, I reference a new VerticalFieldManager called tab1Manager to the tabArea. Tab1Manager has a ListField with a few list items.

 

tabArea = tab1Manager;
add(tabArea);

 

4.Initially when the app starts I display tab1Manager in the tabArea.

 

5.When tab2 is pressed on the tab bar, I first delete the tabArea and reference another VerticalFieldManager called tab2Manager.

 

delete(tabArea);
tabArea = tab2Manager;
add(tabArea);

 

6.Now, what I want to do is when I click an item on the ListField in the tab1Manager, I want to show the tab2Manager on the tabArea. So I implemented something like this

 

protected boolean navigationClick(int status, int time)		
{
Field field = this.getLeafFieldWithFocus();

if(field instanceof ListField)
{
delete(tabArea);
tabArea = tab2Manager;
 add(tabArea);
}

return true;
}

 

Now the problem is I'm getting an IllegalArgumentException when I first click a list item, and then pressing continue on the simulator shows the tab2Manager. On debugging I found that the problem was with the line of code [delete(tabArea)]. The same delete and add code was working when I pressed tab2 (Step no 5). I figured that since the focus is on the listField (and on the tabArea), trying to delete it is creating the problem. But what is the solution?? I've tried removing focus from the tabArea and setFocus to one of the tabs and that worked but that works in two clicks, which is not really what i want.

 

 

P.S: The tabbed strategy employed here was taken from the KB article :

http://supportforums.blackberry.com/t5/Java-Development/Create-tabbed-view-screens/ta-p/444969

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

Re: How to delete a Manager or a Field that is currently on Focus?

On e option might be to put focus on the Tab, then drive the Tabs fieldChanged event.  This should swap you over.  Just a thought.  Not tested...

Please use plain text.
Developer
swati-srivastava
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How to delete a Manager or a Field that is currently on Focus?

try to work with getFieldwithFocusIndex

Please use plain text.
New Developer
JamesPtheNerd
Posts: 14
Registered: ‎06-09-2012
My Device: Red LE Z10; PlayBook, BlackBerry Bold 9780; Torch 9800; Dev Alpha C
My Carrier: Telus Mobility

Re: How to delete a Manager or a Field that is currently on Focus?

[ Edited ]

On e option might be to put focus on the Tab, then drive the Tabs fieldChanged event.  This should swap you over.  Just a thought.  Not tested...

 

This worked for me; thinking back to the original sample code, i had a control on tab1's instance of tabArea; before doing delete(tabArea), I did tab1.setFocus();

--
James Robert Perih
http://www.cardcloud.com/jperih
Please use plain text.