Bottombar: Initialize with empty items and set it at runtime

Created on 26 Sep 2016  路  4Comments  路  Source: roughike/BottomBar

Hello!

I'm currently trying to display some items programmatically on the bottom bar, without initializing them on the XML layout file. Do someone know how to do it? Or at least how to clean the pre-existent ones initialized through xml, so I won't end up with both (xml and programmatically) items on my screen (here at least when I call the getTabCount method, it display the sums of both).

Thanks!

Most helpful comment

I can see the source of BottomBarTab has a method setTitle(https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/BottomBarTab.java#L187) and doesn't seemed to be used anywhere inside the project.

It would be great if we can have a public method to set the both the icon and the title programmatically.

BTW this is very good lib, thanks for the work :)

All 4 comments

I couldn't find a 'nice' way to do it, so this is how I did it:

    BottomBarTab tab = mBottomBar.getTabWithId(R.id.tab_company);
    if (tab != null) {
        TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title);
        if (title != null) {
            title.setText(getTitle(this));
        }
    }

Where R.id.tab_company was the ID I set in the XML for that tab, and getTitle() above would return you the 'custom' text you wanted to use in the icon. May be prone to going horribly wrong in some scenarios, but it seems OK so far :)

I can see the source of BottomBarTab has a method setTitle(https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/BottomBarTab.java#L187) and doesn't seemed to be used anywhere inside the project.

It would be great if we can have a public method to set the both the icon and the title programmatically.

BTW this is very good lib, thanks for the work :)

Plx, put public setTitle

This is fixed in the upcoming 2.1.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nolanus picture Nolanus  路  4Comments

LOG-TAG picture LOG-TAG  路  5Comments

vikramkakkar picture vikramkakkar  路  3Comments

yerenutku picture yerenutku  路  4Comments

ryanhoo picture ryanhoo  路  3Comments