成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Android選項(xiàng)卡具體代碼編寫方式介紹

移動(dòng)開發(fā) Android
Android選項(xiàng)卡的實(shí)現(xiàn),首先需要我們創(chuàng)建一個(gè)TabHost。我們將會(huì)通過一段XML代碼以及Java代碼編寫方式對(duì)這一操作進(jìn)行詳細(xì)介紹。

在對(duì)Android操作系統(tǒng)進(jìn)行相應(yīng)修改中,我們可以發(fā)現(xiàn),這一系統(tǒng)的編程方式非常簡(jiǎn)單易懂,方便開發(fā)人員實(shí)現(xiàn)各種功能需求。在這里就先從Android選項(xiàng)卡的實(shí)現(xiàn)來具體了解一下這一系統(tǒng)的編寫方式。#t#

首先創(chuàng)建Android工程命名自己的Activity為HelloTabWidget

在main.xml或者自己定義的*.xml文件中創(chuàng)建一個(gè)TabHost,需要兩個(gè)元素TabWidget和FrameLayout 通常會(huì)把這兩個(gè)元素放到LinearLayout中。FrameLayout作為改變內(nèi)容content用的。
注意:TabWidget和FrameLayout 有不同的ID命名空間android:id="@android:id/idnames",這個(gè)是必須的因此TabHost才能自動(dòng)找到它,Activity需要繼承TabActivity。

 

Android選項(xiàng)卡Xml代碼

  1. < ?xml version="1.0" encoding="utf-8"?>   
  2. < TabHost xmlns:android=
    "http://schemas.android.com/apk/res/android"   
  3. android:id="@android:id/tabhost"   
  4. android:layout_width="fill_parent"   
  5. android:layout_height="fill_parent">   
  6. < LinearLayout   
  7. android:orientation="vertical"   
  8. android:layout_width="fill_parent"   
  9. android:layout_height="fill_parent">   
  10. < TabWidget   
  11. android:id="@android:id/tabs"   
  12. android:layout_width="fill_parent"   
  13. android:layout_height="wrap_content" />   
  14. < FrameLayout   
  15. android:id="@android:id/tabcontent"   
  16. android:layout_width="fill_parent"   
  17. android:layout_height="fill_parent">   
  18. < TextView   
  19. android:id="@+id/textview1"   
  20. android:layout_width="fill_parent"   
  21. android:layout_height="fill_parent"   
  22. android:text="this is a tab" />   
  23. < TextView   
  24. android:id="@+id/textview2"   
  25. android:layout_width="fill_parent"   
  26. android:layout_height="fill_parent"   
  27. android:text="this is another tab" />   
  28. < TextView   
  29. android:id="@+id/textview3"   
  30. android:layout_width="fill_parent"   
  31. android:layout_height="fill_parent"   
  32. android:text="this is a third tab" />   
  33. < /FrameLayout>   
  34. < /LinearLayout>   
  35. < /TabHost>   
  36.  
  37. < ?xml version="1.0" encoding="utf-8"?> 
  38. < TabHost xmlns:android=
    "http://schemas.android.com/apk/res/android" 
  39. android:id="@android:id/tabhost" 
  40. android:layout_width="fill_parent" 
  41. android:layout_height="fill_parent"> 
  42. < LinearLayout 
  43. android:orientation="vertical" 
  44. android:layout_width="fill_parent" 
  45. android:layout_height="fill_parent"> 
  46. < TabWidget 
  47. android:id="@android:id/tabs" 
  48. android:layout_width="fill_parent" 
  49. android:layout_height="wrap_content" /> 
  50. < FrameLayout 
  51. android:id="@android:id/tabcontent" 
  52. android:layout_width="fill_parent" 
  53. android:layout_height="fill_parent"> 
  54. < TextView   
  55. android:id="@+id/textview1" 
  56. android:layout_width="fill_parent" 
  57. android:layout_height="fill_parent"   
  58. android:text="this is a tab" /> 
  59. < TextView   
  60. android:id="@+id/textview2" 
  61. android:layout_width="fill_parent" 
  62. android:layout_height="fill_parent"   
  63. android:text="this is another tab" /> 
  64. < TextView   
  65. android:id="@+id/textview3" 
  66. android:layout_width="fill_parent" 
  67. android:layout_height="fill_parent"   
  68. android:text="this is a third tab" /> 
  69. < /FrameLayout> 
  70. < /LinearLayout> 
  71. < /TabHost>  

Activity需要繼承TabActivity

Android選項(xiàng)卡Java代碼

  1. public class HelloTabWidget extends TabActivity   
  2. public class HelloTabWidget extends TabActivity  

Android選項(xiàng)卡Java代碼

  1. public void onCreate(Bundle savedInstanceState) {   
  2. super.onCreate(savedInstanceState);   
  3. setContentView(R.layout.main);   
  4. mTabHost = getTabHost();   
  5. mTabHost.addTab(mTabHost.newTabSpec("tab_test1").
    setIndicator("TAB 1").setContent(R.id.textview1));   
  6. mTabHost.addTab(mTabHost.newTabSpec("tab_test2").
    setIndicator("TAB 2").setContent(R.id.textview2));   
  7. mTabHost.addTab(mTabHost.newTabSpec("tab_test3").
    setIndicator("TAB 3").setContent(R.id.textview3));   
  8. mTabHost.setCurrentTab(0);   
  9. }  

Android選項(xiàng)卡的具體實(shí)現(xiàn)方式就為大家介紹到這里。

責(zé)任編輯:曹凱 來源: javaeye.com
相關(guān)推薦

2010-01-27 17:08:01

Android Hel

2010-01-15 16:21:45

VB.NET讀寫文本文

2009-11-24 18:37:55

PHP數(shù)組轉(zhuǎn)換

2009-12-29 18:02:26

SilverLight

2009-12-28 13:23:19

WPF導(dǎo)出圖片

2010-01-04 16:06:34

Silverlight

2009-11-27 13:14:07

PHP函數(shù)strist

2010-01-27 16:35:54

Android常用技巧

2010-01-28 09:45:16

Android Tim

2010-01-26 10:31:32

Android onK

2012-09-17 10:35:41

JavaScriptJS代碼

2022-04-27 16:41:57

微軟Edge瀏覽器

2010-01-26 10:52:01

Android繪圖

2010-02-22 15:13:04

WCF分布式事務(wù)

2010-01-11 13:19:24

C++代碼

2010-02-05 16:49:05

編寫Android 代

2010-01-18 14:35:11

VB.NET讀取內(nèi)存

2015-01-28 14:30:31

android代碼

2021-01-13 13:51:04

鴻蒙HarmonyOSTab選項(xiàng)卡

2010-01-27 14:24:28

Android界面互調(diào)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 久久中文字幕一区 | 天天爽夜夜操 | 色资源在线| 成人免费看电影 | 中国一级大毛片 | 在线免费观看黄色av | 国产精品免费一区二区三区四区 | 欧美福利视频一区 | 天天干天天干 | 国产二区在线播放 | 免费黄色在线观看 | 成人免费看片 | 国产一区二区电影 | 成人综合视频在线观看 | 天天影视综合 | 亚洲毛片在线观看 | 91视视频在线观看入口直接观看 | 精品福利视频一区二区三区 | 日韩欧美在线免费 | www.久草.com | www.99re5.com| 一本在线 | 久久九九免费 | 麻豆视频在线看 | 国产成人高清视频 | 91精品久久久久 | 国产视频在线观看一区二区三区 | 水蜜桃久久夜色精品一区 | 免费的av网站 | 亚洲精品一区二区三区中文字幕 | 欧美一区免费 | 精品无码久久久久久久动漫 | 亚洲视频在线免费观看 | 欧美99| 久久久精品天堂 | 九九热在线观看视频 | 午夜成人在线视频 | 欧美在线播放一区 | 午夜国产羞羞视频免费网站 | 亚洲激情一级片 | 亚洲iv一区二区三区 |