05-14-2010 07:06 PM
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-Develo
05-14-2010 08:29 PM
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...
05-17-2010 08:43 AM
try to work with getFieldwithFocusIndex
01-15-2013 03:22 PM - edited 01-15-2013 03:23 PM
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();