Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to find out the number of Tabs in a TabActivity?

I create tabs dynamically in a TabActivity. Is there a simple way to ask for the number of existing Tabs?

like image 746
Janusz Avatar asked Jul 21 '11 12:07

Janusz


2 Answers

Maybe a bit of a workaround, but you should be able to use: getTabHost().getTabWidget().getTabCount().

I just tested this in my app and it worked correctly.

See here for more info: http://developer.android.com/reference/android/widget/TabWidget.html#getTabCount()

like image 137
stephendnicholas Avatar answered Nov 15 '22 21:11

stephendnicholas


    TabLayout tabLayout = findViewById(R.id.tabs);
    int totalTabs = tabLayout.getTabCount();
like image 43
live-love Avatar answered Nov 15 '22 19:11

live-love