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

3

11

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

Halm answered 21/7, 2011 at 12:13 Comment(0)
O
18

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()

Orgell answered 21/7, 2011 at 12:26 Comment(0)
M
7
    TabLayout tabLayout = findViewById(R.id.tabs);
    int totalTabs = tabLayout.getTabCount();
Madalinemadalyn answered 27/11, 2018 at 19:34 Comment(0)
M
3

To get number of Tab Use

tabHost.getTabWidget().getChildCount() // tabHost is the instance of TabHost
Ma answered 21/7, 2011 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.