Flex combox labelFunction 使用樣本

來源:互聯網
上載者:User
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical"verticalAlign="middle"backgroundColor="white"><mx:Script><![CDATA[import mx.utils.StringUtil;import mx.controls.Alert;[Bindable]private var arr:Array=[{name:"名字11",abbrev:"Al1"},{name:"名字12",abbrev:"Al2"},{name:"名字13",abbrev:"Al3"},{name:"名字14",abbrev:"Al4"},];private function comboBox_labelFunc(item:Object):String {return StringUtil.substitute("{0} ({1})", item.@name, item.@abbrev);}private function comboBox_labelFunc_custom(item:Object):String {return StringUtil.substitute("{0} ({1})", item.name, item.abbrev);}protected function button1_clickHandler(event:MouseEvent):void{if(this.comboBox2.selectedItem)Alert.show(this.comboBox2.selectedItem.name);else Alert.show("not selected");if(this.comboBox.selectedItem)Alert.show(this.comboBox.selectedItem.@name);else Alert.show("not selected");}]]></mx:Script><mx:XMLList id="statesXMLList"><state abbrev="AL" name="Alabama" /><state abbrev="AK" name="Alaska" /><state abbrev="AZ" name="Arizona" /><state abbrev="AR" name="Arkansas" /><state abbrev="CA" name="California" /><state abbrev="CO" name="Colorado" /><state abbrev="CT" name="Connecticut" /></mx:XMLList><mx:ComboBox id="comboBox2" prompt="Please select a aa..." dataProvider="{arr}" labelFunction="comboBox_labelFunc_custom" /><mx:Button label="按鈕" click="button1_clickHandler(event)"/><mx:ComboBox id="comboBox" prompt="Please select a State..." dataProvider="{statesXMLList}" labelFunction="comboBox_labelFunc" /></mx:Application>

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.