Windows下字元編碼轉換

來源:互聯網
上載者:User

標籤:tabhost

有時候經常使用別人用Tabhost+其它的實現demo。單純利用Tabhost該如何使用呢?

下面看例子:

public class MainActivity extends TabActivity {public TabHost tabHost;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 擷取對象tabHost = getTabHost();tabHost.addTab(tabHost.newTabSpec("index").setIndicator("即時新聞").setContent(new Intent(this, IndexActivity.class)));tabHost.addTab(tabHost.newTabSpec("center").setIndicator("我的空間").setContent(new Intent(this, MiddleActivity.class)));tabHost.addTab(tabHost.newTabSpec("self").setIndicator("設定").setContent(new Intent(this, LastActivity.class)));// 指定的當前的tab// 通過索引指定 索引從0開始// 即一開始要顯示的是哪一頁tabHost.setCurrentTab(0); // 從零開始}@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;}}
二、


(2)Tabhost選項卡置於底部的例子

採用LinearLayout布局,設定Weight屬性就可以將選項卡位於底部

1、xml布局檔案

<?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:background="@android:color/white"    android:orientation="vertical" >    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical" >        <FrameLayout            android:id="@android:id/tabcontent"            android:layout_width="fill_parent"            android:layout_height="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), getResources().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), getResources().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), getResources().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、



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.