Flex控件之repeater和radioButton应用
来源:互联网 发布:office办公软件mac版 编辑:程序博客网 时间:2024/05/15 00:44
代码:http://www.cnblogs.com/modou/articles/2108346.html
<?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" minWidth="955" minHeight="600"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.FlexEvent; protected function button1_clickHandler(event:MouseEvent):void { Alert.show(radiogroup1.selectedValue.toString()); } protected function radiobutton1_creationCompleteHandler(event:FlexEvent):void { var rb:RadioButton =event.currentTarget as RadioButton; if(rb==radiogroup1.getRadioButtonAt(2)) { rb.selected = true; } } ]]> </fx:Script> <fx:Declarations> <fx:Array id="arr"> <fx:Object label="北京" data="010" /> <fx:Object label="上海" data="021" /> <fx:Object label="天津" data="022" /> <fx:Object label="重庆" data="023" /> <fx:Object label="广州" data="020" /> </fx:Array> <s:RadioButtonGroup id="radiogroup1" /> </fx:Declarations> <s:Button x="336" y="316" label="按钮" click="button1_clickHandler(event)"/> <mx:VBox x="100" y="200" height="200" width="200" borderVisible="true" borderStyle="outset"> <mx:Repeater dataProvider="{arr}" id="radioRepeater" x="52" y="38"> <s:RadioButton label="{radioRepeater.currentItem.label}" value="{radioRepeater.currentItem.data}" groupName="radiogroup1"
creationComplete="radiobutton1_creationCompleteHandler(event)" /> </mx:Repeater> </mx:VBox> </s:Application>
1.首先先用fx:Array生成数据对象,fx:Array需要放在fx:Declarations声明部分
2.添加一个s:RadioButtonGroup,也需要放在fx:Declarations声明部分
3.添加一个mx:Repeater组件,并在mx:Repeater组件内添加一个s:RadioButton组件给mx:Repeater组件设置数据源,那么数据源有几条数据,就会生成几个RadioButton
由于mx:Repeater组件必须包在基于Halo的容器中,所以还需要在mx:Repeater组件外包一个mx:VBox组件
4.通过radiogroup1.selectedValue.toString(),可以获取当前选择项的value值
5.如果需要默认绑定第一个RadioButton,可以在RadioButton组件添加creationComplete事件,监测如果是第一项,就选中
0 0
- Flex控件之repeater和radioButton应用
- Flex RadioButton 分组使用repeater
- Flex Repeater控件注意
- 13-界面控件之RadioButton和CheckBox
- Android按钮控件之RadioGroup和RadioButton
- Android控件之RadioGroup和RadioButton
- Android控件之RadioButton和RadioGroup
- Android控件之Checkbox和RadioButton
- 前台应用----------Repeater控件
- Repeater控件的应用
- Repeater控件的应用
- Repeater控件的应用
- flex 入门学习笔记3 之RadioButton和RadioButtonGroup
- flex repeater控件Repeater is not executing"的异常
- 前台应用----------嵌套repeater控件
- RadioButton控件和RadioButtonList控件
- CheckBox和RadioButton应用
- Android常见控件之RadioGroup,RadioButton,CheckBox和Toast
- JAVA6学习webservice
- datagrid和combobox简单应用
- WebService调用一对多关联关系时出现 死循环:A cycle is detected in...
- Flex之DataGrid和Tree控件的数据源XML格式
- Flex应用一览表
- Flex控件之repeater和radioButton应用
- cas server 配置一些警告问题
- Codeforces Round #230 (Div. 2) C: Blocked Points 水泄不通的点墙
- 静态链表实现的两种方法
- HTML5标签改变
- Iframe的应用以及父窗口和子窗口的相互访问
- iframe和frame的区别
- java webservice的多种实现方法汇总
- HTML5标签应用