0

I would like to add multiple tabs on my android App. The number of tabs are dynamic based on the database value. I would like to display first three tabs directly and keep other tabs under a " = " button. How can I do that ? Whats the term for displaying tabs like that ?( Like bootstrap responsive nav bar ). This is how I add tabs.

final TabHost tabHost = getTabHost();


    if (condition) {

        TabSpec inboxSpec = tabHost.newTabSpec(name1);


        inboxSpec.setIndicator(name1);
        Intent inboxIntent = new Intent(this, web.class);
        inboxIntent.putExtra("vide", oId);
        inboxSpec.setContent(inboxIntent);
        tabHost.addTab(inboxSpec); // Adding Inbox tab

    }
    ......
    ......

Please help. I am not familiar with android.

Tabs As the picture show I need a toggle button and need to list remaining tabs like the above picture.

Mijoe
  • 236
  • 2
  • 9

1 Answers1

0

You can perform this through loops .. try like this ..

for(int i = 1; i < 10; i++)
        {
            String getTab = "TAB_" + i + "_TAG";
            mTabHost.addTab(
                    mTabHost.newTabSpec(getTab).setIndicator("",
                            getResources().getDrawable(R.drawable.tab_select_talk)),
                    TalkContainerFragment.class, null);
        }

This is basic idea for accomplishing your task ..

For Creating tabs try this ...Dynamically changing the fragments inside a fragment tab host?

Hope it helps .. Cheers !

UPDATE

Actually you don't need Tab Navigation .. instead you need Spinner Navigation of ActionBar..
Please have a look at this tutorial .. This contains all you need .. http://www.androidhive.info/2013/11/android-working-with-action-bar/

Community
  • 1
  • 1
AndroidHacker
  • 3,596
  • 1
  • 25
  • 45