02-14-2012 06:06 PM
Hi,
I've been experimenting with a TabbedView app. If I put a button on each of 2 views the views are put in the same view space instead of the other tab. Is there a way to get the second tab to get focus when the button is pushed? As it is now the button pushes the view in the first tab.
From one view
navigator.popAll();
navigator.pushView(ListView);
From the other view
navigator.popAll();
navigator.pushView(ItemsView);
The second tab does not get used at all. Everything seems to be done in the first tab.
Neil
Solved! Go to Solution.
02-22-2012 04:59 PM
Without troubleshooting your source all I can recommend is having a look at Adobe’s documentation on defining tabs located here.
02-22-2012 05:10 PM
That is my source in the button click event. Other than that the tabs and mxml docs were created when the app was created.
Neil
02-24-2012 03:51 PM
That documentation says:
"Each ViewNavigator maintains a separate navigation stack. Therefore, the ViewNavigator methods, such as pushView() and popView()
, are relative to the currently active section. The back button on the mobile device returns control to the previous view on the stack of the current ViewNavigator. The change of view does not alter the current section."
and
"To change sections programmatically, set the TabbedViewNavigator.selectedIndex
property to the index of the desired section. Section indexes are 0-based: the first section in the application is at index 0, the second is at index 1, and so on."
Have you tried that?
02-24-2012 05:19 PM
There is no selectedIndex in the navigator. There is a tabindex that can be set to 0 but that does nothing.
02-24-2012 05:50 PM
Try "tabbedNavigator.selectedIndex"
That's what it appeared as in my sample app, attached.
02-24-2012 06:17 PM
I'm not sure you understand what I was trying to do. Setup a tabbed app with Tab1 and Tab2.
Insert the code for Tab1 and Tab2 below:
<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="Tab1"> <fx:Script> <![CDATA[ import spark.components.ViewMenuItem; import spark.components.supportClasses.ViewNavigatorAction; import spark.events.ViewNavigatorEvent; protected function button1_clickHandler(event:MouseEvent):void { navigator.tabIndex=1; } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <s:Button x="428" y="488" label="Tab1" click="button1_clickHandler(event)"/> </s:View>
<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="Tab2"> <fx:Script> <![CDATA[ protected function button1_clickHandler(event:MouseEvent):void { navigator.tabIndex=0; } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <s:Button x="292" y="274" label="Tab2" click="button1_clickHandler(event)"/> </s:View>
Neil
02-28-2012 02:59 PM
You're right, I'm doing a lot of guessing to figure out what you are doing to recreate it here. What is the rest of your application?
02-28-2012 03:46 PM
Hi Tim,
I was just trying to see if the tabs could be accessed via code instead of clicking on the bottom bar. It wasn't being used in an application just for self learning.
Here's the scenario. You have 3 tabs on the bottom of the screen. Normally you would click each tab to get to the contents of that tab. I wanted to be able to do it in code rather than have to click on the bottom tab that I wanted to access. I should be able to do it via the index number for the tab but it does not work.
Neil
02-28-2012 04:45 PM
Try using this:
FlexGlobals.topLevelApplication.tabbedNavigator.se
1 being the tab number you want selected in this case