Flex - Contrôle TabNavigator

introduction

Le contrôle TabNavigator est un conteneur de navigateur qui a une collection de conteneurs enfants, mais un seul d'entre eux à la fois est visible.

Déclaration de classe

Voici la déclaration pour mx.containers.TabNavigator classe -

public class TabNavigator 
   extends ViewStack 
      implements IFocusManagerComponent

Propriétés protégées

Sr.Non Propriété et description
1

tabBar : mx.controls:TabBar

Une référence à la TabBar à l'intérieur de ce TabNavigator.

2

tabBarStyleFilters : Object

[lecture seule] L'ensemble des styles à passer de TabNavigator à tabBar.

Méthodes publiques

Sr.Non Méthode et description
1

TabNavigator()

Constructeur.

2

getTabAt(index:int):Button

Renvoie l'onglet du contrôle TabBar du navigateur à l'index spécifié.

Méthodes protégées

Sr.Non Méthode et description
1

measure():void

[override] Calcule les tailles par défaut et les valeurs minimum et maximum de ce conteneur TabNavigator.

2

updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

[override] Répond aux changements de taille en définissant les positions et les tailles des onglets et des enfants de ce conteneur.

Méthodes héritées

Cette classe hérite des méthodes des classes suivantes -

  • mx.containers.ViewStack
  • mx.core.Container
  • mx.core.UIComponent
  • mx.core.FlexSprite
  • flash.display.Sprite
  • flash.display.DisplayObjectContainer
  • flash.display.InteractiveObject
  • flash.display.DisplayObject
  • flash.events.EventDispatcher
  • Object

Exemple de contrôle Flex TabNavigator

Suivons les étapes suivantes pour vérifier l'utilisation du contrôle TabNavigator dans une application Flex en créant une application de test -

Étape La description
1 Créez un projet avec un nom HelloWorld sous un package com.tutorialspoint.client comme expliqué dans le chapitre Flex - Créer une application .
2 Modifiez HelloWorld.mxml comme expliqué ci-dessous. Gardez le reste des fichiers inchangé.
3 Compilez et exécutez l'application pour vous assurer que la logique métier fonctionne conformément aux exigences.

Voici le contenu du fichier mxml modifié src/com.tutorialspoint/HelloWorld.mxml.

<?xml version = "1.0" encoding = "utf-8"?>
<s:Application xmlns:fx = "http://ns.adobe.com/mxml/2009"
   xmlns:s = "library://ns.adobe.com/flex/spark"
   xmlns:mx = "library://ns.adobe.com/flex/mx
   width = "100%" height = "100%" minWidth = "500" minHeight = "500">
   
   <fx:Style source = "/com/tutorialspoint/client/Style.css" />	   
   <s:BorderContainer width = "630" height = "480" id = "mainContainer" 
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50" 
         horizontalAlign = "center" verticalAlign = "middle">
      <s:Label id = "lblHeader" text = "Complex Controls Demonstration" 
         fontSize = "40" color = "0x777777" styleName = "heading" />
            
         <s:Panel id = "tabNavigatorPanel" title = "Using TabNavigator" 
            width = "500" height = "300" >
            <s:layout>
               <s:HorizontalLayout  gap = "10" verticalAlign = "middle" 
                  horizontalAlign = "center" />	
            </s:layout>				
               
            <mx:TabNavigator id = "tabNavigator" width = "95%" height = "90%">
               <s:NavigatorContent label = "Section 1" width = "100%" 
                  height = "100%">
                  <s:VGroup verticalAlign = "middle" horizontalAlign = "center" 
                     width = "100%" height = "100%">
                     <s:Label text = "Contents for Section 1" />	
                  </s:VGroup>							
               </s:NavigatorContent>
                  
               <s:NavigatorContent label = "Section 2" width = "100%" 
                  height = "100%">
                  <s:VGroup verticalAlign = "middle" horizontalAlign = "center"
                     width = "100%" height = "100%">
                     <s:Label text = "Contents for Section 2" />	
                  </s:VGroup>							
               </s:NavigatorContent>
                  
               <s:NavigatorContent label = "Section 3" width = "100%" 
                  height = "100%">
                  <s:VGroup verticalAlign = "middle" horizontalAlign = "center" 
                     width = "100%" height = "100%">
                     <s:Label text = "Contents for Section 3" />	
                  </s:VGroup>							
               </s:NavigatorContent>
                  
               <s:NavigatorContent label = "Section 4" width = "100%" 
                  height = "100%">
                  <s:VGroup verticalAlign = "middle" horizontalAlign = "center" 
                     width = "100%" height = "100%">
                     <s:Label text = "Contents for Section 4" />	
                  </s:VGroup>							
               </s:NavigatorContent>
            </mx:TabNavigator>
         </s:Panel>
      </s:VGroup>	 
   </s:BorderContainer>	
</s:Application>

Une fois que vous êtes prêt avec tous les changements effectués, laissez-nous compiler et exécuter l'application en mode normal comme nous l'avons fait dans le chapitre Flex - Créer une application . Si tout va bien avec votre application, elle produira le résultat suivant: [ ]