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

Android HelloWord編寫方式介紹

移動開發 Android
Android HelloWord程序的實現可以通過這里介紹的代碼編寫方式實現。希望初學者們可以以此為參考對象,對這一應用方式有所了解。

相信學過編程的人員都對各種語言的helloword程序的編寫方式記憶猶新吧。在這里我們就為大家詳細介紹一下有關Android HelloWord的編寫方式,方便大家對這一操作系統編寫方式的理解。#t#

先說說整個程序要做哪些內容吧,簡單helloword 通過一個按鈕點擊在另一個acitvity出現文本Hello xiaoshengDAI

 

 

 

說下Android HelloWord做的步驟吧:

 

1.首先新建項目,我這邊主要是測試Layout所以項目名就叫這個了。

2.我們要顯示一個按鈕,難后點擊這個按鈕就轉到其他activity顯示Hello xiaoshengDAI,新建類Layout主要來顯示***個activity即button,

1).在main.xml文件中進行配置

Java代碼

  1. < ?xml version="1.0" encoding="utf-8"?>   
  2. < LinearLayout xmlns:android=
    "http://schemas.android.com/apk/res/android"   
  3. android:orientation="vertical"   
  4. android:layout_width="fill_parent"   
  5. android:layout_height="fill_parent">   
  6. < Button android:id="@+id/button1"   
  7. android:layout_width="wrap_content"   
  8. android:layout_height="wrap_content"   
  9. android:text="來點我吧"/>   
  10. < /LinearLayout>   
  11. < ?xml version="1.0" encoding="utf-8"?> 
  12. < LinearLayout xmlns:android=
    "http://schemas.android.com/apk/res/android" 
  13. android:orientation="vertical" 
  14. android:layout_width="fill_parent" 
  15. android:layout_height="fill_parent">   
  16. < Button android:id="@+id/button1"   
  17. android:layout_width="wrap_content"   
  18. android:layout_height="wrap_content"   
  19. android:text="來點我吧"/>   
  20. < /LinearLayout>  

 

 

 

2).設置監聽和跳轉actiovity

 

 

Java代碼

  1. package com.layout;   
  2. import android.app.Activity;   
  3. import android.content.Intent;   
  4. import android.os.Bundle;   
  5. import android.view.View;   
  6. import android.view.View.OnClickListener;   
  7. import android.widget.Button;   
  8. public class Layout extends Activity {   
  9. /** Called when the activity is first created. */   
  10. @Override   
  11. public void onCreate(Bundle savedInstanceState) {   
  12. OnClickListener listener1 = null;   
  13. Button botton1 = null;   
  14. listener1 = new OnClickListener(){   
  15. public void onClick(View v) {   
  16. Intent intent0 = new Intent(Layout.this,
    ActivityFrameLayout.class);   
  17. setTitle("FrameLayout");   
  18. startActivity(intent0);   
  19. }   
  20. };   
  21. super.onCreate(savedInstanceState);   
  22. setContentView(R.layout.main);   
  23. botton1 = (Button) findViewById(R.id.button1);   
  24. botton1.setOnClickListener(listener1);   
  25. }   
  26. }   
  27. package com.layout;  
  28. import android.app.Activity;  
  29. import android.content.Intent;  
  30. import android.os.Bundle;  
  31. import android.view.View;  
  32. import android.view.View.OnClickListener;  
  33. import android.widget.Button;  
  34. public class Layout extends Activity {  
  35. /** Called when the activity is first created. */  
  36. @Override  
  37. public void onCreate(Bundle savedInstanceState) {  
  38. OnClickListener listener1 = null;  
  39. Button botton1 = null;   
  40. listener1 = new OnClickListener(){  
  41. public void onClick(View v) {   
  42. Intent intent0 = new Intent(Layout.this,
    ActivityFrameLayout.class);   
  43. setTitle("FrameLayout");  
  44. startActivity(intent0);  
  45. }   
  46. };   
  47. super.onCreate(savedInstanceState);  
  48. setContentView(R.layout.main);  
  49. botton1 = (Button) findViewById(R.id.button1);  
  50. botton1.setOnClickListener(listener1);  
  51. }  

 

3.在Android HelloWord編寫中,新建activityFrameLayout類和activityFrameLayout.xml文件

 

Java代碼

  1. < ?xml version="1.0" encoding="utf-8"?>   
  2. < LinearLayout xmlns:android=
    "http://schemas.android.com/apk/res/android"   
  3. android:orientation="vertical"   
  4. android:layout_width="fill_parent"   
  5. android:layout_height="fill_parent"   
  6. >   
  7. < TextView   
  8. android:layout_width="fill_parent"   
  9. android:layout_height="wrap_content"   
  10. android:text="Hello xiaoshengDAI"   
  11. />   
  12. < /LinearLayout>   
  13. < ?xml version="1.0" encoding="utf-8"?> 
  14. < LinearLayout xmlns:android=
    "http://schemas.android.com/apk/res/android" 
  15. android:orientation="vertical" 
  16. android:layout_width="fill_parent" 
  17. android:layout_height="fill_parent" 
  18. > 
  19. < TextView   
  20. android:layout_width="fill_parent"   
  21. android:layout_height="wrap_content"   
  22. android:text="Hello xiaoshengDAI" 
  23. /> 
  24. < /LinearLayout>  

 

Java代碼

  1. package com.layout;   
  2. import android.app.Activity;   
  3. import android.os.Bundle;   
  4. public class ActivityFrameLayout extends Activity {   
  5. @Override   
  6. protected void onCreate(Bundle savedInstanceState) {   
  7. super.onCreate(savedInstanceState);   
  8. setTitle("哈哈");   
  9. setContentView(R.layout.activityframelayout);   
  10. }   
  11. }   
  12. package com.layout;  
  13. import android.app.Activity;  
  14. import android.os.Bundle;  
  15. public class ActivityFrameLayout extends Activity {  
  16. @Override  
  17. protected void onCreate(Bundle savedInstanceState) {  
  18. super.onCreate(savedInstanceState);  
  19. setTitle("哈哈");  
  20. setContentView(R.layout.activityframelayout);  
  21. }  

4.對AndroidManifest.xml進行配置,將新建Activity配置文件加進來

 

Android HelloWord的Java代碼

  1. < ?xml version="1.0" encoding="utf-8"?>   
  2. < manifest xmlns:android=
    "http://schemas.android.com/apk/res/android"   
  3. package="com.layout"   
  4. android:versionCode="1"   
  5. android:versionName="1.0">   
  6. < application android:icon="@drawable/icon" 
    android:label="@string/app_name">   
  7. < activity android:name=".Layout"   
  8. android:label="@string/app_name">   
  9. < intent-filter>   
  10. < action android:name="android.intent.action.MAIN" />   
  11. < category android:name=
    "android.intent.category.LAUNCHER" />   
  12. < /intent-filter>   
  13. < /activity>   
  14. < activity android:name=".ActivityFrameLayout" 
    android:label="activityFrameLayout">   
  15. < intent-filter>   
  16. < action android:name="android.intent.action.MAIN" />   
  17. < category android:name=
    "android.intent.category.LAUNCHER" />   
  18. < /intent-filter>   
  19. < /activity>   
  20. < /application>   
  21. < uses-sdk android:minSdkVersion="3" />   
  22. < /manifest>   
  23. < ?xml version="1.0" encoding="utf-8"?> 
  24. < manifest xmlns:android=
    "http://schemas.android.com/apk/res/android" 
  25. package="com.layout" 
  26. android:versionCode="1" 
  27. android:versionName="1.0"> 
  28. < application android:icon="@drawable/icon" 
    android:label="@string/app_name"> 
  29. < activity android:name=".Layout" 
  30. android:label="@string/app_name"> 
  31. < intent-filter> 
  32. < action android:name="android.intent.action.MAIN" /> 
  33. < category android:name=
    "android.intent.category.LAUNCHER" /> 
  34. < /intent-filter> 
  35. < /activity> 
  36. < activity android:name=".ActivityFrameLayout" 
    android:label="activityFrameLayout"> 
  37. < intent-filter> 
  38. < action android:name="android.intent.action.MAIN" /> 
  39. < category android:name=
    "android.intent.category.LAUNCHER" /> 
  40. < /intent-filter> 
  41. < /activity> 
  42. < /application> 
  43. < uses-sdk android:minSdkVersion="3" /> 
  44. < /manifest>  

5.Android HelloWord可以運行了,嘿嘿

責任編輯:曹凱 來源: javaeye.com
相關推薦

2010-01-27 16:30:47

Android選項卡

2010-01-27 16:35:54

Android常用技巧

2010-01-28 09:45:16

Android Tim

2010-01-26 10:31:32

Android onK

2010-01-25 13:29:53

Android本地應用

2010-01-15 16:21:45

VB.NET讀寫文本文

2010-01-27 15:15:13

Android多媒體錄

2010-02-22 11:14:43

Python編寫

2010-04-07 12:08:28

Oracle存儲過程

2012-05-10 15:21:50

JavaScript

2009-12-22 15:14:33

WCF調用

2010-02-22 14:18:34

WCF服務驗證

2009-08-27 14:32:15

C#編寫ActiveX

2012-09-17 10:35:41

JavaScriptJS代碼

2023-05-22 15:35:10

JavaScriptWeb開發

2010-09-07 13:04:14

CSS Hack

2009-12-28 13:23:19

WPF導出圖片

2009-11-24 18:37:55

PHP數組轉換

2019-11-23 15:45:38

Web指紋識別指紋

2009-12-29 18:02:26

SilverLight
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲欧洲小视频 | 羞羞视频在线观看 | 国产成年人小视频 | 观看毛片 | 91最新视频| 日韩精品一区二区三区第95 | 精品亚洲一区二区三区 | 日日噜噜噜夜夜爽爽狠狠视频, | 91色啪| 亚洲精品久久久久中文字幕欢迎你 | 日韩av一区二区在线观看 | 一二区成人影院电影网 | 日韩欧美一区二区在线播放 | 黄色国产在线播放 | 日韩免费 | 久久国产精品-国产精品 | 欧美在线a | 国产精品久久久久久久午夜片 | 黄色国产在线视频 | 久久久久99 | 看黄在线 | 国产一区二区观看 | 精品国产一区二区三区性色 | 中文字幕在线观看一区二区 | 欧美日韩综合一区 | 人和拘一级毛片c | 欧美日韩高清 | xxxxx免费视频| 欧美日韩国产在线 | 欧美久久不卡 | 成人欧美一区二区 | 极品电影院 | 天天干天天干 | 91久久夜色精品国产网站 | 日韩免费毛片视频 | 免费看一区二区三区 | 91精品久久久久 | 国产人成精品一区二区三 | 国产精品18久久久久久久 | 91超碰在线观看 | 一级毛片视频在线 |