Android第一課——HelloWorld

來源:互聯網
上載者:User

標籤:總結   ges   src   lin   etc   public   extc   cte   roi   

Hello World!

1.activity_main布局檔案


 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:background="#ff0000" 6     android:orientation="horizontal" > 7      8     <TextView  9         android:id="@+id/hello"10         android:layout_width="match_parent"11         android:layout_height="wrap_content"12         android:text="@string/hello_world"13         android:textSize="20sp"14         android:layout_gravity="center"15         android:gravity="center"16         android:textColor="#ff000000"/>17 18 </LinearLayout>
2.MainActivity實現功能

 

 1 package com.helloworld; 2  3 import android.app.Activity; 4 import android.os.Bundle; 5  6 public class MainActivity extends Activity { 7  8     @Override 9     protected void onCreate(Bundle savedInstanceState) {10         super.onCreate(savedInstanceState);11         setContentView(R.layout.activity_main);12     }13 }

 3.運行效果:

 
4.學習總結:
Android項目開發,先需要布局好檔案,也就是xml檔案。而後去java中實現準系統,在java中把布局檔案一一對應好。
座右銘:抱怨沒有用,一切靠自己!

 

Android第一課——HelloWorld

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.