Character encoding conversion under Windows

Source: Internet
Author: User

Sometimes people use tabhost+ other implementations of the demo. How to use tabhost simply?

Let's look at the example below:

public class Mainactivity extends tabactivity {public tabhost tabhost; @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate);//Get Object tabhost = Gettabhost (); Tabhost.addtab ( Tabhost.newtabspec ("index"). Setindicator ("Real-time News"). SetContent (New Intent (this, indexactivity.class))); Tabhost.addtab (Tabhost.newtabspec ("center"). Setindicator ("My Space"). SetContent (New Intent (This, Middleactivity.class)); Tabhost.addtab (Tabhost.newtabspec ("Self"). Setindicator ("Settings"). SetContent (New Intent (this , Lastactivity.class)));//The current tab//specified by index specifies the index starting from 0//which page to display at the beginning Tabhost.setcurrenttab (0); Zero-based} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action Bar if It is Present.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}
Two


(2) Tabhost tab at the bottom of the example

With the LinearLayout layout, you can set the weight property to place the tab at the bottom

1. XML layout file

<?xml version= "1.0" encoding= "Utf-8"? ><tabhost xmlns:android= "Http://schemas.android.com/apk/res/android "Android:id=" @+id/tabhost "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "Android:bac Kground= "@android: Color/white" android:orientation= "vertical" > <linearlayout android:layout_width= "Mat            Ch_parent "android:layout_height=" match_parent "android:orientation=" vertical "> <framelayout Android:id= "@android: Id/tabcontent" android:layout_width= "Fill_parent" Android:layout_heig ht= "0dip" android:layout_weight= "1.0" > </FrameLayout> <tabwidget android:        Id= "@android: Id/tabs" android:layout_width= "match_parent" android:layout_height= "Wrap_content" > </TabWidget> </LinearLayout></TabHost>
2, Mainactivity

public class Mainactivity extends activitygroup{private tabhost mtabhost;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main);    Inittabs ();        } private void Inittabs () {mtabhost = (tabhost) Findviewbyid (r.id.tabhost);                Mtabhost.setup (This.getlocalactivitymanager ());        Intent Intent = new Intent (this, homepageactivity.class); Mtabhost.addtab (Mtabhost.newtabspec ("Tab1"). Setindicator (GetString (r.string.homepage_indicator), Getresour               CES (). getdrawable (R.drawable.homepage_indicator_selector)). SetContent (intent));        Intent = new Intent (this, billboardactivity.class); Mtabhost.addtab (Mtabhost.newtabspec ("Tab2"). Setindicator (GetString (r.string.billboard_indicator), Getresou   RCEs (). getdrawable (R.drawable.billboard_indicator_selector)). SetContent (intent));             Intent = new Intent (this, mylotteryactivity.class); Mtabhost.addtab (Mtabhost.newtabspec ("Tab3"). Setindicator (GetString (r.string.mylottery_indicator), Getresou                RCEs (). getdrawable (R.drawable.mylottery_indicator_selector)). SetContent (intent));        Intent = new Intent (this, moreactivity.class); Mtabhost.addtab (Mtabhost.newtabspec ("Tab4"). Setindicator (GetString (R.string.more_indicator), Getresources (    ). Getdrawable (R.drawable.more_indicator_selector)). SetContent (intent)); }}
3.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.