I did the same this in past. Follow the steps:
First get all the Tab Setup data from DB.
add Tab as per there Number which is coming from DB and in my requirement i want to show 4 Tab only. Create a loop like
for (int j = 0; j < 4 && j < cursor.getCount(); j++) { addTab1(tab_title_from_DB, tab_image_from_DB,tab_fragement_class, 0, 1); }
Now,in
addTab1(...)
i loaded myCustom_tab_indicator layout
and bind the data and add tab into Tabhost likemTabHost.addTab(spec);
At last step i set
mTabHost.setCurrentTab(0);
to select my First Tab
Update: you must set Tab Indicator
like photospec.setIndicator("", ressources.getDrawable(R.drawable.icon_windows_config))
to your TabSpec
TabSpec is used to set Indicator, Content, Label, Icon, etc. on the particular tab. I have created TabSpec object which will initialized by newTabSpec method or TabHost class, which will have tag or title as parameter.
setIndicator will indicate TabHost that particular tab is selected or not. The file icon_windows_config
in /res/drawable
will indicate that tab is selected of not. This file will set background of tabs on the basis of that tab is selected of not.
You can to it for your all Tab.