android學習三---建立第一個程式

來源:互聯網
上載者:User

標籤:android   style   blog   http   io   ar   os   使用   sp   

1.建立一個Helloworld程式1.1 new-android application

點擊file-new-android application出現如下介面

 

填上應用程式名稱,項目名,包名,選擇所需最低的SDK版本,目標版本和編譯版本,next next

選擇一個Activity,預設是blank。然後Finish。

就建立好一個android項目了。不需要添加任何代碼,就可以運行了。

2.建立虛擬機器和在真機上運行2.1 模擬器運行

開啟工具列上AVD的按鈕

出現建立VD(虛擬機器)的介面

點擊creat就可以建立了。

主要有Android 虛擬裝置的名稱( Name)、目標的 Target( SDK)、 SD Card 的路徑,以及虛擬設備的 Skin等

紅色標註的兩項:一個是選擇CPU有ARM和X86(Atom)。二是類比方式

Snaphost和Use Host GPU這兩者的區別

The Snapshot option speeds up the boot of the emulator by saving a snapshot of its RAM once it has booted, and restoring from that snapshot on future uses. That way, it doesn‘t have to run the boot process (which is slow, because it‘s emulated) every time you start the emulator.

The Use Host GPU option uses the host computer‘s OpenGL implementation (which is probably hardware-accelerated, on your real GPU) to evaluate OpenGL commands inside the emulated system. Put another way, when a program inside the emulator uses OpenGL for graphics operations, the work goes out to your real GPU, and the result goes back into the emulator, instead of emulating a GPU (which is very slow). The result is a significant speed-up, especially when you consider that most view and canvas drawing uses OpenGL in Android ≥ 4, even in non-graphics apps.

You can‘t have both options turned on at once.

Snapshot通過boot時儲存RAM的快照來加速模擬器的啟動。所以每次啟動模擬器時不需要運行boot過程。

Use Host GPU :使用宿主要電腦的OpenGL實現,當emulator需要使用OpenGL時,會使用電腦的GPU,而不用類比,所以可以加速一些圖形處理。

如果電腦效能一般般,最好還是選Snapshot。

出現如上的節目表示建立成功。在這之前請耐心等待,啟動過程很久。

簡單的運用程式

2.2 真機運行

需要一台android手機,能夠串連電腦,並下好驅動。這時點Run as android application。就會有機器出現在下面的選項中,

 

如果有android手機最好選擇真機進行調試,虛擬機器啟動太慢了,安裝,已耗用時間也很久。

 

3.android項目目錄結構

 

 

 

 

主要介紹幾個

3.1 src :

是項目的所有包及源檔案( .java)主要實現應用的功能等

3.2 res:

檔案夾中則包含了項目中
的所有資源,比如,程式表徵圖( drawable)、布局檔案( layout)、常量( values)等

3.3 gen:

代表的是自動建立的檔案,其中R.java 是在建立項目時自動產生的,這個檔案是唯讀模式,不能更改, R.java 檔案是定義該項目所有
資源的索引檔案。

3.4 AndroidManfest.xml:

AndroidManfest.xml 檔案則包含了該項目中所使用的 Activity、 Service、 Receiver。

android學習三---建立第一個程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.