课程表

Flex课程

工具箱
速查手册

ToggleButtonBar控件

当前位置:免费教程 » 软件/图像 » Flex

介绍

ToggleButtonBar控件提供了一组水平或垂直按钮,以保持其选定或取消选择的状态。

类声明

以下是 mx.controls.ToggleButtonBar 类的声明:

  1. public class ToggleButtonBar
  2. extends ButtonBar

公共属性

S.N.属性和描述
1

selectedIndex:int

[override]所选按钮的索引。

2

toggleOnClick:Boolean

指定是否可以由用户取消选择当前选择的按钮。

公共方法

S.N.方法和描述
1

ToggleButtonBar()

构造函数。

继承的方法

此类继承以下类中的方法:

  • mx.controls.ButtonBar

  • mx.controls.NavBar

  • mx.containers.Box

  • 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

Flex ToggleButtonBar控件示例

让我们按照以下步骤通过创建测试应用程序来检查Flex应用程序中ToggleButtonBar控件的用法:

步骤描述
1 Flex - 创建应用程序章节中所述,在包 com.tutorialspoint.client 下创建名为 HelloWorld 的项目。
2修改 HelloWorld.mxml ,如下所述。 保持文件的其余部分不变。
3编译并运行应用程序,以确保业务逻辑按照要求工作。

以下是修改后的mxml文件 src / com.tutorialspoint / HelloWorld.mxml 的内容。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3. xmlns:s="library://ns.adobe.com/flex/spark"
  4. xmlns:mx="library://ns.adobe.com/flex/mx"
  5. width="100%" height="100%" minWidth="500" minHeight="500"
  6. >
  7. <fx:Style source="/com/tutorialspoint/client/Style.css"/>
  8. <fx:Script>
  9. <![CDATA[
  10. import mx.events.ItemClickEvent;
  11. private function sectionClickHandler(event:ItemClickEvent):void {
  12. sectionContents.text = "Contents for " + event.label;
  13. }
  14. ]]>
  15. </fx:Script>
  16. <fx:Declarations>
  17. <fx:Array id="sectionList">
  18. <fx:String>Section 1</fx:String>
  19. <fx:String>Section 2</fx:String>
  20. <fx:String>Section 3</fx:String>
  21. <fx:String>Section 4</fx:String>
  22. <fx:String>Section 5</fx:String>
  23. </fx:Array>
  24. </fx:Declarations>
  25. <s:BorderContainer width="630" height="480" id="mainContainer"
  26. styleName="container">
  27. <s:VGroup width="100%" height="100%" gap="50"
  28. horizontalAlign="center" verticalAlign="middle">
  29. <s:Label id="lblHeader" text="Complex Controls Demonstration"
  30. fontSize="40" color="0x777777" styleName="heading"/>
  31. <s:Panel id="toggleButtonBarPanel" title="Using ToggleButtonBar"
  32. width="500" height="300" >
  33. <s:layout>
  34. <s:VerticalLayout gap="10" verticalAlign="middle"
  35. horizontalAlign="center" paddingTop="10"/>
  36. </s:layout>
  37. <mx:ToggleButtonBar itemClick="sectionClickHandler(event);"
  38. dataProvider="{sectionList}" />
  39. <s:BorderContainer width="90%" height="70%"
  40. borderColor="0x323232">
  41. <s:VGroup verticalAlign="middle"
  42. horizontalAlign="center" width="100%" height="100%">
  43. <s:Label id="sectionContents"
  44. text="Contents for Section 1"/>
  45. </s:VGroup>
  46. </s:BorderContainer>
  47. </s:Panel>
  48. </s:VGroup>
  49. </s:BorderContainer>
  50. </s:Application>

准备好所有更改后,让我们以正常模式编译和运行应用程序,就像在 Flex - 创建应用程序中一样 章节。 如果一切顺利,您的应用程序,这将产生以下结果:[在线试用]

Flex ToggleButtonBar Control
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号