2013-08-05 20 views
0

在Flex手機應用程序,我想有一個ButtonBar在底部,我需要改變其按鈕的標籤:如何更改標籤在ButtonBar - 簡單的測試案例和屏幕截圖附加

enter image description here

(我不想在這裏使用TabbedViewNavigatorApplication,因爲我所有的邏輯都在一個單獨的View中,頂部有一個ActionBar,底部有ButtonBar)。

所以我準備了一個非常簡單的測試用例來演示我的問題。

請在Flash Builder中創建一個「空白」Flex移動項目,並將其中的2個文件(下面)放入其中,您將看到我的問題 - 觸摸底部的按鈕不會更改最右邊的標籤按鈕)。

TestAC.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" 
       applicationDPI="160"> 
    <fx:Script> 
     <![CDATA[ 
      import spark.events.IndexChangeEvent; 
      import spark.skins.mobile.TabbedViewNavigatorTabBarSkin; 

      private function handleTabs(event:IndexChangeEvent):void { 
       trace(_tabBar.selectedIndex); 
       _tabs[2].label = String(1 + _tabBar.selectedIndex); 
      } 
     ]]> 
    </fx:Script> 
    <fx:Declarations> 
     <s:MultiDPIBitmapSource id="CHAT" 
      source160dpi="@Embed('chat.png')" 
      source240dpi="@Embed('chat.png')" 
      source320dpi="@Embed('chat.png')" /> 

     <s:ArrayCollection id="_tabs"> 
      <fx:Object label="One" /> 
      <fx:Object label="Two" /> 
      <fx:Object label="Three" icon="{CHAT}" /> 
     </s:ArrayCollection> 
    </fx:Declarations> 

    <s:ButtonBar id="_tabBar" 
       requireSelection="true" 
       width="100%" 
       bottom="0" 
       skinClass="spark.skins.mobile.TabbedViewNavigatorTabBarSkin" 
       dataProvider="{_tabs}" 
       change="handleTabs(event)"> 
    </s:ButtonBar> 

</s:Application> 

chat.png:

enter image description here

回答

0

還好吧,加入_tabs.refresh();handleTabs幫助。

相關問題