You can use TabHost to switch between different la s on a single screen. The tabhost interface provided by the system is simple. How can we optimize custom modification?
MainActivity source code
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 (); Intent 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 (""); 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, the background style tabHost is updated. listener (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 = (RelativeLayout) 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 (); params. width = RelativeLayout. layoutParams. MATCH_PARENT; params. height = RelativeLayout. layoutParams. MATCH_PARENT; text. setLayoutParams (params); text. setGravity (Gravity. CENTER); if (mTabHost. getCurrentTab () = I) {// select tabView. setBackgroundColor (Color. parseColor ("# 8DB6CD"); text. setTextColor (this. getResources (). getColorStateList (android. r. color. black);} else {// The tabView is not selected. setBackgroundColor (Color. parseColor ("# ffffff"); text. setTextColor (this. getResources (). getColorStateList (android. r. color. darker_gray ));}}}}