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

解析Android Widget組件應用學習

移動開發
Android Widget組件應用學習是本文要介紹的內容,主要是來了解并學習Android Widget組件應用,來看詳細內容。

Android Widget組件應用學習是本文要介紹的內容,主要是來了解并學習Android Widget組件應用,具體內容的學習來看本文詳解。

這里是Android基本組件Button和Tab_Widget的簡單應用,通過點擊Tab1、Tab2、Tab3、來切換查看內容

圖為加入TabView按鈕的Activity和點擊Tab切換效果演示

Android Widget組件應用學習 

Android Widget組件應用學習     Android Widget組件應用學習

項目名為:Tab

代碼如下:

  1. package com.tab.demo;  
  2. import android.app.Activity;  
  3. import android.content.Intent;  
  4. import android.os.Bundle;  
  5. import android.view.View;  
  6. import android.widget.Button;  
  7. public class MainActivity extends Activity {  
  8.       
  9. private Button button; //構建按鈕對象  
  10. public void onCreate(Bundle savedInstanceState) {  
  11. super.onCreate(savedInstanceState);  
  12. setContentView(R.layout.main);  
  13. button=(Button)findViewById(R.id.tab_demo_button); //實例化對象,聯系到布局文件  
  14. button.setOnClickListener(new Button.OnClickListener() {  
  15. //設置監聽器,監聽點擊事件  
  16. @Override  
  17. public void onClick(View v) {  
  18. // TODO Auto-generated method stub  
  19. Intent intent = new Intent();  
  20. intent.setClass(MainActivity.this, TabDemoActivity.class);  
  21. startActivity(intent); //實現點擊跳轉  
  22. }  
  23. });  
  24. }  
  25. }  
  26. //跳轉到TabDemoActivity的代碼   
  27.  
  28. package com.tab.demo;  
  29. import android.app.TabActivity;  
  30. import android.os.Bundle;  
  31. import android.view.LayoutInflater;  
  32. import android.widget.TabHost;  
  33. public class TabDemoActivity extends TabActivity {  
  34. public void onCreate(Bundle savedInstanceState) {  
  35. super.onCreate(savedInstanceState);  
  36. TabHost tabHost = getTabHost(); //構造一個Tab標簽容器TabHost  
  37. LayoutInflater.from(this).inflate(R.layout.tab_demo,  
  38. tabHost.getTabContentView(), true);  
  39. tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Tab1")  
  40. .setContent(R.id.view1)); //分別把構造好的標簽放入TabHost里面  
  41. tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Tab2")  
  42. .setContent(R.id.view2));  
  43. tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Tab3")  
  44. .setContent(R.id.view3));  
  45. }  

MainActivity的視圖布局文件 main xml:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:orientation="vertical" android:layout_width="fill_parent" 
  4. android:layout_height="fill_parent"> 
  5. <TextView android:layout_width="fill_parent" 
  6. android:layout_height="wrap_content" android:text="@string/hello" /> 
  7. <Button android:layout_width="wrap_content" 
  8. android:layout_height="wrap_content" android:text="TabView" 
  9. android:id="@+id/tab_demo_button" /> 
  10. </LinearLayout> 

TabDemoActivity 的視圖布局文件 tab_demo xml:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:layout_width="fill_parent" 
  4.     android:layout_height="fill_parent"> 
  5.     <TextView android:id="@+id/view1" 
  6.         android:background="@drawable/one" 
  7.         android:layout_width="fill_parent" 
  8.         android:layout_height="fill_parent" 
  9.         android:text="@string/tab1"/> 
  10.     <TextView android:id="@+id/view2" 
  11.         android:background="@drawable/three" 
  12.         android:layout_width="fill_parent" 
  13.         android:layout_height="fill_parent" 
  14.         android:text="@string/tab2"/> 
  15.     <TextView android:id="@+id/view3" 
  16.         android:background="@drawable/two" 
  17.         android:layout_width="fill_parent" 
  18.         android:layout_height="fill_parent" 
  19.         android:text="@string/tab3"/> 
  20. </FrameLayout> 

相關信息文件string xml :

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <resources> 
  3.     <string name="hello">Hello World, Tab!</string> 
  4.     <string name="app_name">Tab</string> 
  5.     <string name"tab1">Here is tab1.</string> 
  6.     <string name"tab2">Jump to Tab2.</string> 
  7.     <string name"tab3">The end is Tab3.</string> 
  8. </resources> 

應用配置文件 AndroidMainfest xml :

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  3. package="com.tab.demo" android:versionCode="1" android:versionName="1.0"> 
  4. <application android:icon="@drawable/me" android:label="@string/app_name"> 
  5. <activity android:name=".MainActivity" android:label="@string/app_name"> 
  6. <intent-filter> 
  7. <action android:name="android.intent.action.MAIN" /> 
  8. <category android:name="android.intent.category.LAUNCHER" /> 
  9. </intent-filter> 
  10. </activity> 
  11. <activity android:name=".TabDemoActivity"></activity> 
  12. </application> 
  13. </manifest>  

小結:解析Android Widget組件應用學習的內容介紹完了,希望通過Android組件Tab_Widget內容的學習能對你有所幫助!

責任編輯:zhaolei 來源: 博客園
相關推薦

2011-09-07 14:25:53

Android Wid設計

2011-09-09 17:59:26

QT Widget

2011-09-08 16:07:13

Widget配置文件

2011-09-09 11:05:56

Widget

2011-09-08 15:51:33

Android Wid組件

2011-09-09 19:23:52

Widget

2011-09-07 14:20:42

Android Wid組件

2011-09-07 17:54:40

Android Wid開發

2011-09-07 10:58:07

Android wid

2011-09-07 14:01:41

Android Wid實例

2011-09-09 10:00:20

Android Wid開發

2011-02-28 13:04:27

RelativeLayAndroid Wid

2011-09-07 16:28:46

QT WidgetQWidget

2011-09-07 16:36:00

Qt Widget

2011-09-07 14:39:47

Android Wid設計

2015-01-12 13:48:55

Android應用組件

2011-09-08 13:11:07

Android Wid實例

2011-09-07 13:30:48

Android WidTabWidget

2011-09-07 13:42:36

Android Wid實例

2011-09-07 11:15:25

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产一区91精品张津瑜 | 欧美激情网站 | 欧美日韩视频网站 | 中文字幕亚洲一区二区三区 | 国产日韩一区二区 | www.亚洲区| ww 255hh 在线观看 | 国产精品一区二区三区在线 | 国产一区二区视频免费在线观看 | 中文字幕日韩专区 | 欧美成人一区二免费视频软件 | 欧美一区二区三区大片 | 一区二区三区欧美 | 亚洲精品在线免费播放 | 超碰高清| 91国内精品久久 | 综合天天久久 | 午夜羞羞| 精品欧美一区二区精品久久 | 国产成人福利在线 | av网站免费观看 | 国产一区二区三区日韩 | 久热精品在线 | 午夜精品久久久久久久久久久久久 | 日韩专区中文字幕 | 欧美日韩一区二区在线播放 | 成人性视频免费网站 | 在线观看视频福利 | 国产97在线看 | 国产成人综合一区二区三区 | 午夜激情影院 | 久草久草久草 | 午夜成人免费视频 | 精品一区二区久久久久久久网精 | 欧美中文在线 | 色狠狠一区 | 欧美性网| 人人爽人人爽人人片av | 日韩一级在线 | 中文字幕乱码一区二区三区 | 国产精品一区久久久 |