【讀書筆記-《Android遊戲編程之從零開始》】6.Android 遊戲開發常用的系統控制項(TabHost、ListView)

來源:互聯網
上載者:User

3.9 TabSpec與TabHost

TabHost類官方文檔地址:http://developer.android.com/reference/android/widget/TabHost.html

Android 實現tab視圖有2種方法,一種是在布局頁面中定義<tabhost>標籤,另一種就是繼承tabactivity.但是我比較喜歡第二種方式,應為如果頁面比較複雜的話你的XML檔案會寫得比較龐大,用第二種方式XML頁面相對要簡潔得多。

                                      
  MainActivity  TabActivity  TabSpec ts1, ts2, ts3;     TabHost tabHost; = .getTabHost();        LayoutInflater.from(= tabHost.newTabSpec("tabOne");        ts1.setIndicator("分頁1");        ts1.setContent(R.id.btn);        ts2 = tabHost.newTabSpec("tabTwo"        ts2.setIndicator("分頁2"= tabHost.newTabSpec("tabThree""分頁3"        tabHost.addTab(ts1);          (tabId.equals("tabOne", "分頁1" (tabId.equals("tabTwo", "分頁2" (tabId.equals("tabThree", "分頁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.