The example in this article describes how Android simply implements the tab menu at the bottom of the screen. Share to everyone for your reference, specific as follows:
See a lot of popular Android programs (such as: Sina Weibo, Tencent Weibo, Jingdong Mall, Taobao, when, etc.) using tabbed style as the main frame structure of the program interface, and the Android tab control defaults to the button on top. I've seen a variety of implementations on the Web, offering a personal feeling of simplicity. Because I know very little about Android development, the pros and cons of the method is not good at present, you are welcome to provide better ideas.
Main principle: sets the android:layout_alignparentbottom= "true" implementation of the Tabwidget control.
Main.xml:
<?xml version= "1.0" encoding= "Utf-8"?> <tabhost android:id= "@+id/tabhost" xmlns:android= "http://" Schemas.android.com/apk/res/android "android:orientation=" vertical "android:layout_width=" Fill_parent "Android: layout_height= "Fill_parent" > <relativelayout android:orientation= "vertical" android:layout_width= "Fill_" Parent "android:layout_height=" fill_parent > <tabwidget android:id= "@android: Id/tabs" android:layout_width = "Fill_parent" android:layout_height= "Wrap_content" android:layout_alignparentbottom= "true"/> <FrameLayou
T android:id= "@android: Id/tabcontent" android:layout_width= "fill_parent" android:layout_height= "Fill_parent" >
<linearlayout android:id= "@+id/tab1" android:layout_width= "fill_parent" android:layout_height= "Fill_parent"
androidrientation= "vertical" > <textview android:id= "@+id/view1" android:layout_width= "Wrap_content" Android:layout_height= "Wrap_content" Android: text= "@string/textview_1"/> </LinearLayout> <linearlayout android:id= "@+id/tab2" Android : layout_width= "fill_parent" android:layout_height= "fill_parent" androidrientation= "vertical" > <TextV Iew android:id= "@+id/view2" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:tex t= "@string/textview_2"/> </LinearLayout> <linearlayout android:id= "@+id/tab3" Android:lay Out_width= "Fill_parent" android:layout_height= "fill_parent" androidrientation= "vertical" > <textview Android:id= "@+id/view3" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "@ String/textview_3 "/> </LinearLayout> <linearlayout android:id=" @+id/tab4 "Android:layout_" Width= "Fill_parent" android:layout_height= "fill_parent" androidrientation= "vertical" > <textview andr Oid:id= "@+id/view4" AndrOid:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "@string/textview_4"/>
</LinearLayout> </FrameLayout> </RelativeLayout> </TabHost>
Zhnews.java:
package net.zhnews.android; import android.app.Activity; import android.os.Bundle; import
Android.widget.TabHost; The public class Zhnews extends activity {/** called the ' when the ' is the ' The activity ' is a./@Override public void created
Ate (Bundle icicle) {super.oncreate (icicle);
Setcontentview (R.layout.main);
Settitle ("Zhuhai News Network Android Client");
Tabhost tabs = (tabhost) Findviewbyid (r.id.tabhost);
Tabs.setup ();
Tabhost.tabspec spec = Tabs.newtabspec ("Tab1");
Spec.setcontent (R.ID.TAB1);
Spec.setindicator ("News");
Tabs.addtab (spec);
Spec = Tabs.newtabspec ("tab2");
Spec.setcontent (R.ID.TAB2);
Spec.setindicator ("The search of the Yonhap");
Tabs.addtab (spec);
Spec = Tabs.newtabspec ("Tab3");
Spec.setcontent (R.ID.TAB3);
Spec.setindicator ("image");
Tabs.addtab (spec);
Spec = Tabs.newtabspec ("Tab4");
Spec.setcontent (R.ID.TAB4);
Spec.setindicator ("Settings");
Tabs.addtab (spec);
Tabs.setcurrenttab (0); }
}
For more information on Android-related content readers can view the site: "Android Multimedia how-to Summary (audio, video, recording, etc.)", "Android Development introduction and Advanced Course", "Android view summary of the tips", " The activity Operation skill summary of Android programming, "Android operation SQLite database Skill Summary", "Android operation JSON format Data technique summary", "Android database Operation skill Summary", "Android File Operation skill Summary "," Android programming development of SD card operation method Summary "," Android Resource Operation skills Summary "and" Android Control usage Summary "
I hope this article will help you with the Android program.