編輯:高級開發
相信學過編程的人員都對各種語言的helloWord程序的編寫方式記憶猶新吧。在這裡我們就為大家詳細介紹一下有關android HelloWord的編寫方式,方便大家對這一操作系統編寫方式的理解。
先說說整個程序要做哪些內容吧,簡單helloWord 通過一個按鈕點擊在另一個acitvity出現文本Hello xiaoshengDAI
說下android HelloWord做的步驟吧:
1.首先新建項目,我這邊主要是測試Layout所以項目名就叫這個了。
2.我們要顯示一個按鈕,難後點擊這個按鈕就轉到其他activity顯示Hello xiaoshengDAI,新建類Layout主要來顯示第一個activity即button,
1).在main.XML文件中進行配置
Java代碼
- < ?XML version="1.0" encoding="utf-8"?>
- < LinearLayout XMLns:android=
"http://schemas.android.com/apk/res/android"- android:orIEntation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- < Button android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="來點我吧"/>
- < /LinearLayout>
- < ?XML version="1.0" encoding="utf-8"?>
- < LinearLayout XMLns:android=
"http://schemas.android.com/apk/res/android"- android:orIEntation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- < Button android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="來點我吧"/>
- < /LinearLayout>
2).設置監聽和跳轉actiovity
Java代碼
- package com.layout;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.VIEw;
- import android.view.VIEw.OnClickListener;
- import android.widget.Button;
- public class Layout extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- OnClickListener listener1 = null;
- Button botton1 = null;
- listener1 = new OnClickListener(){
- public void onClick(VIEw v) {
- Intent intent0 = new Intent(Layout.this,
ActivityFrameLayout.class);- setTitle("FrameLayout");
- startActivity(intent0);
- }
- };
- super.onCreate(savedInstanceState);
- setContentVIEw(R.layout.main);
- botton1 = (Button) findVIEwById(R.id.button1);
- botton1.setOnClickListener(listener1);
- }
- }
- package com.layout;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.VIEw;
- import android.view.VIEw.OnClickListener;
- import android.widget.Button;
- public class Layout extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- OnClickListener listener1 = null;
- Button botton1 = null;
- listener1 = new OnClickListener(){
- public void onClick(VIEw v) {
- Intent intent0 = new Intent(Layout.this,
ActivityFrameLayout.class);- setTitle("FrameLayout");
- startActivity(intent0);
- }
- };
- super.onCreate(savedInstanceState);
- setContentVIEw(R.layout.main);
- botton1 = (Button) findVIEwById(R.id.button1);
- botton1.setOnClickListener(listener1);
- }
- }
3.在android HelloWord編寫中,新建activityFrameLayout類和activityFrameLayout.XML文件
Java代碼
- < ?XML version="1.0" encoding="utf-8"?>
- < LinearLayout XMLns:android=
"http://schemas.android.com/apk/res/android"- android:orIEntation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- < TextVIEw
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Hello xiaoshengDAI"
- />
- < /LinearLayout>
- < ?XML version="1.0" encoding="utf-8"?>
- < LinearLayout XMLns:android=
"http://schemas.android.com/apk/res/android"- android:orIEntation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- < TextVIEw
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Hello xiaoshengDAI"
- />
- < /LinearLayout>
Java代碼
- package com.layout;
- import android.app.Activity;
- import android.os.Bundle;
- public class ActivityFrameLayout extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTitle("哈哈");
- setContentVIEw(R.layout.activityframelayout);
- }
- }
- package com.layout;
- import android.app.Activity;
- import android.os.Bundle;
- public class ActivityFrameLayout extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTitle("哈哈");
- setContentVIEw(R.layout.activityframelayout);
- }
- }
4.對androidManifest.XML進行配置,將新建Activity配置文件加進來
android HelloWord的Java代碼
- < ?XML version="1.0" encoding="utf-8"?>
- < manifest XMLns:android=
"http://schemas.android.com/apk/res/android"- package="com.layout"
- android:versionCode="1"
- android:versionName="1.0">
- < application android:icon="@drawable/icon"
android:label="@string/app_name">- < activity android:name=".Layout"
- android:label="@string/app_name">
- < intent-filter>
- < action android:name="android.intent.action.MAIN" />
- < category android:name=
"android.intent.category.LAUNCHER" />- < /intent-filter>
- < /activity>
- < activity android:name=".ActivityFrameLayout"
android:label="activityFrameLayout">- < intent-filter>
- < action android:name="android.intent.action.MAIN" />
- < category android:name=
"android.intent.category.LAUNCHER" />- < /intent-filter>
- < /activity>
- < /application>
- < uses-sdk android:minSdkVersion="3" />
- < /manifest>
- < ?XML version="1.0" encoding="utf-8"?>
- < manifest XMLns:android=
"http://schemas.android.com/apk/res/android"- package="com.layout"
- android:versionCode="1"
- android:versionName="1.0">
- < application android:icon="@drawable/icon"
android:label="@string/app_name">- < activity android:name=".Layout"
- android:label="@string/app_name">
- < intent-filter>
- < action android:name="android.intent.action.MAIN" />
- < category android:name=
"android.intent.category.LAUNCHER" />- < /intent-filter>
- < /activity>
- < activity android:name=".ActivityFrameLayout"
android:label="activityFrameLayout">- < intent-filter>
- < action android:name="android.intent.action.MAIN" />
- < category android:name=
"android.intent.category.LAUNCHER" />- < /intent-filter>
- < /activity>
- < /application>
- < uses-sdk android:minSdkVersion="3" />
- < /manifest>
5.android HelloWord可以運行了,嘿嘿
隨著Google的android手機和蘋果的iPhone手機的逐漸普及,越來越多開發者加入到移動應用開發的大軍當中。目前移動終端中的冠亞軍android,應用是基於Ja
ello-jni,hello-jni 為 aPPS 下 hello-jni 文件夾的名稱,這個命令會先找到 aPPS\hello-jni 下地 Application.
android 作為谷歌企業戰略的重要組成部分,這個戰略大大的提高了谷歌在中國手機界的市場,也大大的促進了整個手機行業的競爭性,下面就向大家介紹下android手機程序
一般是一些被軟件工程師用於為特定的軟件包、軟件框架、硬件平台、操作系統等建立應用軟件的開發工具的集合,這種android SDK 安全性有助於減少惡意應用程序損害設備的