The use of tabhost can be in a screen between different layout of the switch, and the system comes with a simple tabhost interface, we should be how to customize the modification of the optimization?
Source code for Mainactivity
Package Com.dream.ledong;import Android.app.tabactivity;import Android.content.intent;import Android.graphics.color;import Android.os.bundle;import Android.view.gravity;import android.widget.RelativeLayout; Import Android.widget.tabhost;import Android.widget.tabhost.ontabchangelistener;import android.widget.TabWidget; Import Android.widget.textview;import COM.EXAMPLE.CLIENT.R; @SuppressWarnings ("Deprecation") public class ItemList Extends Tabactivity {@Overridepublic void onCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setcontentview (r.layout.itemlist); final Tabhost tabhost = GetTabHost (); I Ntent remoteintent = new Intent (itemlist.this, Item1.class); Tabhost.tabspec Remotetabspec = Tabhost.newtabspec ("remote"); Remotetabspec.setindicator ("Motion Recommendation"); Remotetabspec.setcontent (remoteintent); Tabhost.addtab (Remotetabspec); Intent localintent = new Intent (itemlist.this , Item2.class); Tabhost.tabspec Localtabspec = Tabhost.newtabspec ("local"); localTabspec.setindicator ("ball friend Chi"); Localtabspec.setcontent (localintent); Tabhost.addtab (LOCALTABSPEC); Intent LocalIntent2 = new Intent (itemlist.this, Item2.class); Tabhost.tabspec localTabSpec2 = Tabhost.newtabspec ("a"); Localtabspec2.setindicator ("competitive atmosphere"); Localtabspec2.setcontent (LocalIntent2); Tabhost.addtab (LOCALTABSPEC2); Updatetabstyle (tabhost);//When a tab is selected, update the background style Tabhost.setontabchangedlistener (new Ontabchangelistener () {@ overridepublic void ontabchanged (String tabId) {updatetabstyle (tabhost);}}); private void Updatetabstyle (final tabhost mtabhost) {Tabwidget tabwidget = Mtabhost.gettabwidget (); Tabwidget.setrightstripdrawable (r.drawable.list_item_divide_operate); Tabwidget.setleftstripdrawable ( R.drawable.list_item_divide_operate); for (int i = 0; i < Tabwidget.getchildcount (); i++) {Relativelayout TabView = (Rel Ativelayout) Mtabhost.gettabwidget (). Getchildat (i); TextView Text = (TextView) tabwidget.getchildat (i). Findviewbyid (Android. R.id.title); text.settextsize (15); Relativelayout.laYoutparams params = (relativelayout.layoutparams) text.getlayoutparams ();p arams.width = Relativelayout.layoutparams.match_parent;params.height = RelativeLayout.LayoutParams.MATCH_PARENT; Text.setlayoutparams (params); Text.setgravity (Gravity.center), if (mtabhost.getcurrenttab () = = i) {//Check Tabview.setbackgroundcolor ( Color.parsecolor ("#8DB6CD")); Text.settextcolor (This.getresources (). Getcolorstatelist (Android. R.color.black));} else {//unchecked Tabview.setbackgroundcolor (Color.parsecolor ("#ffffff")); Text.settextcolor (This.getresources (). Getcolorstatelist (Android. R.color.darker_gray));}}}