Http://www.cnblogs.com/shirley-1019/archive/2013/04/10/3012824.html
Very nice piece of code:
public class Tabhosttestactivity extends tabactivity implements
tabcontentfactory {
private string[] lables = new string[] {"Home", "message", "friend", "more"};
Private int[] icons = new int[] {r.drawable.ic_home, r.drawable.ic_msg, R.drawable.ic_friend, r.drawable.ic_more};
/** called when the activity is first created. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.tabhost);
Tabhost th = Gettabhost ();
Tabhost = Gettabhost ();
for (int i = 0; i < lables.length; i++) {
View view = Layoutinflater.from (this). Inflate (R.layout.menu, NULL);
ImageView Menu_ic = (ImageView) View.findviewbyid (r.id.menu_ic);
Menu_ic.Setimageresource(Icons[i]);
TextView Text = (TextView) View.findviewbyid (r.id.menu_lable);
Text.SetText(Lables[i]);
Tabhost.addtab (Tabhost.newtabspec (string.valueof (i)). Setindicator (view). SetContent (this));
}
Tabhost.setcurrenttab (0); }
@Override
public void ontabchanged (String tabId) {
TabId is the string passed in Newtabspec (string tag) tag, where tag is 0,1,2,3 can be converted to plastic for easy judgment
int TabID = integer.valueof (TabID);
for (int i = 0; i < Mtabwidget.getchildcount (); i++) {
if (i = = TabID) {
Mtabwidget.getchildat (i). Setbackgroundresource (
R.drawable.indicator_selected);
} else {
Mtabwidget.getchildat (i). Setbackgroundresource (
R.drawable.indicator_unselected);
}
}
}
Tabhost switching activity by gesture
Http://www.eoeandroid.com/thread-238527-1-1.html's a blast.
Enable scrolling of tags in Android tabhost