2014-10-02 20 views
0

ButtonBar是否可能只顯示viewstack中的一些導航器內容。比如說,我只想讓按鈕欄顯示前兩個按鈕,而不是第三個按鈕?按鈕欄只能顯示它提供的Viewstack的某些內容嗎?

<s:ButtonBar dataProvider="{mainViewStack}"/> 
<mx:ViewStack id="mainViewStack"> 
<s:NavigatorContent> 
</s:NavigatorContent> 
<s:NavigatorContent> 
</s:NavigatorContent> 
<s:NavigatorContent> 
</s:NavigatorContent> 
</mx:ViewStack> 

回答

0

我有類似的問題,沒有找到本地解決方案。所以我寫了下一個「黑客」。 寫了擴展NavitagorContent的自己的類。

ExtNavigatorContent.as

public class ExtNavigationContent extends NavigatorContent 
{ 
    public function ExtNavigationContent() 
    { 
     super(); 
    } 

    private var _includeInBar:Boolean = true; 

    public function get includeInBar():Boolean 
    { 
     return _includeInBar; 
    } 

    public function set includeInBar(value:Boolean):void 
    { 
     _includeInBar = value; 
     dispatchEvent(new Event("labelChanged")); 
    } 
} 

我創造了新的皮膚的TabBar(在你的情況下,將按鈕欄)。然後,添加在標準皮膚在下一個(而不是默認ButtonBarButton創建):

<s:ButtonBarButton includeInLayout="{data.includeInBar}" visible="{data.includeInBar}" buttonMode="true"/> 

,終於宣佈的TabBar /按鈕欄:

<s:TabBar id="menu" dataProvider="{viewstack1}" skinClass="design.skins.tabbar.SimpleTabBarSkin"/> 
<mx:ViewStack id="viewstack1" width="100%" height="100%"> 
    <components:ExtNavigationContent includeInBar="false" /> 
    <components:ExtNavigationContent includeInBar="true" /> 
    <components:ExtNavigationContent /> 
</mx:ViewStack> 
+0

謝謝你的回答,我會嘗試這一點,如果它對我有效,請提供反饋。 :)希望有一個更簡單的解決方案,但好吧。 – Omgabee 2014-10-03 13:54:31

+0

我無法得到這個工作....我只是要嘗試一種不同的方法來實現我想要的。 – Omgabee 2014-10-03 16:12:10

+0

對不起,我舉了一個不正確的例子。我會更新答案。如果您的解決方案出現問題,請寫信給我,我會盡力提供幫助。 – Crabar 2014-10-06 05:32:58

相關問題