如何以编程方式隐藏底栏中的项目

时间:2017-02-23 08:43:44

标签: java android bottombar

我正在使用This Library添加底栏。我想用户可以通过过滤器启用禁用项目应该显示或隐藏哪个选项卡。但我无法以编程方式隐藏项目。有没有办法以编程方式隐藏选项卡。

TABS

<?xml version="1.0" encoding="utf-8"?>
<tabs>
<tab
    id="@+id/facebook"
    icon="@drawable/ic_facebook_logo"
    title="facebook"
    inActiveColor="#ffffff"
    barColorWhenSelected="#3b5998"
    activeColor="#ffffff"
    />
<tab
    id="@+id/googleplus"
    icon="@drawable/ic_google"
    title="google+"
    inActiveColor="#ffffff"
    activeColor="#ffffff"
    barColorWhenSelected="#dd4b39"/>
<tab
    id="@+id/twitter"
    icon="@drawable/ic_twitter_social"
    title="twitter"
    barColorWhenSelected="#00aced"
    inActiveColor="#ffffff"

    activeColor="#ffffff"
    />
<tab
    id="@+id/instagram"
    icon="@drawable/ic_instagram_social"
    title="instagram"
    inActiveColor="#ffffff"

    activeColor="#ffffff"
    barColorWhenSelected="#cd486b"/>
<tab
    id="@+id/linkedin"
    icon="@drawable/ic_linkedin_logo"
    title="linkedin"
    inActiveColor="#ffffff"
    barColorWhenSelected="#0077b5"
    activeColor="#ffffff"
    />
</tabs>

XML

<com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="bottom"
        app:bb_tabXmlResource="@xml/tabs"
        app:bb_behavior="shy"
        app:bb_activeTabAlpha="1"
        app:bb_showShadow="true"
        />

1 个答案:

答案 0 :(得分:1)

你不能做

bottomBar.getTabAtPosition(x).setVisibility(View.GONE);