Android_Studio開發實例多按鈕範例與多國語系


預覽畫面:

 

主要是延續HelloWorld按鈕範例,

改為多按鈕,可以顯示在 EditText 中,也可以清除數字,

重點在使用 LinerLayout 來排版 XML檔

設計好介面之後,再來轉寫程式,以符合MVC的架構

最後補充多國語系設計,讓不同國家使用者,

都能看到自己區域的語系。

以下有些分享畫面分享:

完成設計畫面

畫面XML:

1.方向

2.TextView設定

3.按鈕版形

 

完整教學:

 

介面:

xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:id="@+id/LinearLayout1"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical"

   android:paddingBottom="@dimen/activity_vertical_margin"

   android:paddingLeft="@dimen/activity_horizontal_margin"

   android:paddingRight="@dimen/activity_horizontal_margin"

   android:paddingTop="@dimen/activity_vertical_margin"

   tools:context=".MainActivity" >

 

   

       android:id="@+id/txtShow"

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:text="電話號碼:"

       android:textAppearance="?android:attr/textAppearanceLarge"

       android:textColor="#00FF00"

       android:textSize="30sp" />

 

   

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:gravity="center" >        

           android:id="@+id/b01"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="1" />

 

       

           android:id="@+id/b02"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="2" />

 

       

           android:id="@+id/b03"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="3" />

 

   

 

   

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:gravity="center" >

 

       

           android:id="@+id/b04"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="4" />

 

       

           android:id="@+id/b05"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="5" />

 

       

           android:id="@+id/b06"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="6" />

   

 

   

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:gravity="center" >

 

       

           android:id="@+id/b07"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="7" />

 

       

           android:id="@+id/b08"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="8" />

 

       

           android:id="@+id/b09"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="9" />

   

 

   

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:gravity="center" >

 

       

           android:id="@+id/b10"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="*" />

 

       

           android:id="@+id/b00"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="0" />

 

       

           android:id="@+id/b11"

           android:layout_width="50dp"

           android:layout_height="wrap_content"

           android:text="#" />

   

 

   

       android:id="@+id/bClear"

       android:layout_width="150dp"

       android:layout_height="wrap_content"

       android:layout_gravity="center"

       android:text="清除" />

 

程式設計:

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

 

public class MainActivity extends Activity {

  //1.宣告物件

  TextView txtShow;

  Button b00,b01,b02,b03,b04,b05,b06,b07,b08,b09,b10,b11,bClear;

 

  @Override

  protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      //2.連結元件

      txtShow=(TextView) this.findViewById(R.id.txtShow);

      b00=(Button) this.findViewById(R.id.b00);

      b01=(Button) this.findViewById(R.id.b01);

      b02=(Button) this.findViewById(R.id.b02);

      b03=(Button) this.findViewById(R.id.b03);

      b04=(Button) this.findViewById(R.id.b04);

      b05=(Button) this.findViewById(R.id.b05);

      b06=(Button) this.findViewById(R.id.b06);

      b07=(Button) this.findViewById(R.id.b07);

      b08=(Button) this.findViewById(R.id.b08);

      b09=(Button) this.findViewById(R.id.b09);

      b10=(Button) this.findViewById(R.id.b10);

      b11=(Button) this.findViewById(R.id.b11);

      bClear=(Button) this.findViewById(R.id.bClear);

      //3.建立事件

      b00.setOnClickListener(new View.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"0");

          }});

      b01.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"1");

          }});

      b02.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"2");

          }});

      b03.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"3");

          }});

      b04.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"4");

          }});

      b05.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"5");

          }});

      b06.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"6");

          }});

      b07.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"7");

          }});

      b08.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"8");

          }});

      b09.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"9");

          }});

      b10.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"*");

          }});

      b11.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              txtShow.setText(S+"#");

          }});

      bClear.setOnClickListener(new Button.OnClickListener(){

 

          @Override

          public void onClick(View v) {

              // TODO 自動產生的方法 Stub

              String S=txtShow.getText().toString();

              if (S.length()>5){

                  txtShow.setText(S.substring(0, S.length()-1));

              }

          }});

  }

}

 

**補充多國語系設計

 

 


懶人包:http://terry55wu.blogspot.com/p/android.html

 

課程理念與課程介紹:

Android智慧型手機平台,已成為手機上最完整的開放開發平台

人手必備的趨勢下行動上網已達500萬人次以上,手機相關應用,將會超

越PC,比PC更智慧,更貼近個人使用習慣,未來APP將漸取代Web,成

為各產業或政府對外窗口。

如何開發APP,以循序漸進的方式講授Android應用程式架構、圖形介面

開發、測試與除錯等,進而取得證照。

吳老師教學特色:

1.影音複習分享(全程錄影)。

2.能不硬code程式,有程式也會提供畫面。

3.提供業界實務開發經驗。

4.書上沒講到的操作,圖形化工具使用。

5.隨時更新第一手資訊。

 

參考書目

Android 初學特訓班

作者:鄧文淵/總監製;文淵閣工作室/編著

 

 

發表時間

文章標題

2015-06-15

Android開發實務基本相簿Photoplayer範例

2015-06-15

Android開發實務相簿表格GridView範例

2015-06-13

智慧型手機開發進階SQLite資料庫的存取方式

2015-06-13

智慧型手機進階SQLite資料庫的存取方式

2015-05-25

如何讓圖片有縮放功能(增加TouchImageView類別)

2015-05-18

把Android APP專案轉移Android_Studio分享

2015-03-22

ANDROID APP開發與雲端實務應用(第1次上課建置與開發)

2015-01-28

Android APP程式開發證照教學懶人包(new)

2015-01-16

Android開發實務相簿表格GridView範例

2015-01-16

Android開發實務相簿藝廊Gallery範例

2015-01-16

Android開發實務基本相簿Photoplayer範例

2015-01-16

Android開發實務下拉清單Spinner與樣板

2015-01-16

Android開發實務相簿藝廊Gallery範例

2015-01-16

健行科大Android程式設計實務第4次上課_RadioButton

2015-01-16

Android開發實務Input介面設計與AlertDialog

2015-01-16

Android開發實務多按鈕與多國語系

2015-01-16

Android程式實務第1次上課(馬上建置與開發)

2014-07-13

艾鍗Android行動應用程式設計實務(如何產生功能表選單)

2014-07-13

如何使用ListView 介面元件

2014-07-13

教您學會簡易相簿APP範例Phoneplayer專案

2014-07-13

如何在Android APP的ListView 元件同時加上圖與字

2014-01-12

智慧型手機(Android)設計入門第15次

2014-01-05

智慧型手機(Android)設計入門第14次

2013-09-28

智慧型手機設計入門第2次(102年)

2013-02-03

Android開發實例進階(勞大) 影音DVD完工

2013-01-13

智慧型手機開發實例與證照解析(Android)第18次上課

2013-01-13

建國科大APP產業演講影音(共2小時)

2012-12-22

智慧型手機開發實例與證照解析(Android)第15次上課

2012-12-22

智慧型手機開發實例與證照解析(Android)第11次上課

2012-12-08

智慧型手機開發實例與證照解析(Android)第13次上課

2012-12-08

海洋資通APP開發課程第10次上課

2012-11-18

智慧型手機開發實例與證照解析(Android)第10次上課

2012-11-02

智慧型手機開發實例與證照解析(Android)第9次上課

2012-10-28

智慧型手機開發實例與證照解析(Android)第8次上課

 

想快速學會APP設計與開發,建議可以先從JAVA先聽完並練習,

再學習光碟19,之後銜接光碟21進階或光碟14比較偏證照考試。

或從光碟24_從JAVA入門到智慧型手機設計開始(目錄 http://goo.gl/1XOOG)

另有最近推出的合輯:

光碟30_JAVA7物件導向(2013) 艾鍗學院96小時上課 目錄:

http://goo.gl/Wjbjo9

光碟31_智慧型手機入門(2013) 勞工大學48小時上課 目錄:

http://goo.gl/qMTc9E

光碟32_淡江資工Android證照解題(2013) 淡江資工40小時上課 目錄:

http://goo.gl/q1eQkr

想快速學會APP設計與開發,建議可以先從光碟24--30--31--32


完整教學影音DVD分享申請 [連結]

 

android app教學,android 開發教學,android 程式教學,android eclipse,android 使用教學,Andriod ,android ,程式教學 ,android ,eclipse ,Android Studio,App開發教學,app開發課程,手機app開發教學

arrow
arrow

    吳老師 發表在 痞客邦 留言(0) 人氣()