A short tutorial of how to add an popularize a tabhost container in Android Studio.
- In the design view add a tabhost container.
- Add/remove the tabs as you need and rename the tabs to something meaningful, prefixing the id’s with “tab” might be a good idea, so they can be easily accessed via auto completion.
- In the onCreate function of your activity set up the tabhost
TabHost th = (TabHost) findViewById(R.id.tabHostId); th.setup();
- After the TabHost is setup, add specs for each tab
TabHost.TabSpec ts = th.newTabSpec("tab_name"); ts.setContent(R.id.tabId); ts.setIndicator("Tab Label"); th.addTab(ts);
Repeat Step 4 for each tab you want to add.
THANK YOU , THANK YOU , finally something clear that works !