Flex - TabBar
introduction
La classe TabBar représente un ensemble d'onglets identiques.
Déclaration de classe
Voici la déclaration pour spark.components.TabBar classe -
public class TabBar
extends ButtonBarBase
implements IFocusManagerComponent
Méthodes publiques
Sr.Non | Méthode et description |
---|---|
1 | TabBar() Constructeur. |
Méthodes héritées
Cette classe hérite des méthodes des classes suivantes -
- spark.components.supportClasses.ButtonBarBase
- spark.components.ListBase
- spark.components.SkinnableDataContainer
- spark.components.supportClasses.SkinnableContainerBase
- spark.components.supportClasses.SkinnableComponent
- mx.core.UIComponent
- mx.core.FlexSprite
- flash.display.Sprite
- flash.display.DisplayObjectContainer
- flash.display.InteractiveObject
- flash.display.DisplayObject
- flash.events.EventDispatcher
- Object
Exemple de Flex TabBar
Suivons les étapes suivantes pour vérifier l'utilisation de TabBar 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 = "Layout Panels Demonstration"
fontSize = "40" color = "0x777777" styleName = "heading" />
<s:Panel id = "tabBarPanel" title = "Using TabBar"
width = "500" height = "300" >
<s:layout>
<s:VerticalLayout gap = "0" />
</s:layout>
<s:TabBar id = "tabs" dataProvider = "{viewStack}" left = "5" top = "5" />
<mx:ViewStack id = "viewStack" width = "95%" height = "85%" left = "5">
<s:NavigatorContent label = "Tab #1" width = "100%" height = "100%">
<s:BorderContainer width = "100%" height = "100%" >
<s:Label text = "Content area for Tab #1"
verticalCenter = "0" horizontalCenter = "0" />
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent label = "Tab #2" width = "100%" height = "100%">
<s:BorderContainer width = "100%" height = "100%">
<s:Label text = "Content area for Tab #2"
verticalCenter = "0" horizontalCenter = "0" />
</s:BorderContainer>
</s:NavigatorContent>
</mx:ViewStack>
</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: [ Essayez-le en ligne ]