Lesson1: Installing Eclipse and SDKs
http://www.youtube.com/watch?v=xtsyrKdPZVw&feature=related
1. 下載eclipse:www.eclipse.org
2. 安裝android sdk:developer.android.com/sdk/index.html
按照官網上的步驟,順利安裝Eclipse+android sdk
運行的時候需要開啓模擬器AVD
Lesson 2: Setting up a Project and Explaining the Explaining the Basics
1. 創建一個android項目:打開Eclipse, file->new->android project
2. 自動創建的包結構:
src:java源代碼
gen:自動創建的資源關聯java文件
Android *.*:可能需要的import導入包
res:資源,圖片(drawable,3種圖片質量)、聲音、佈局layout、字符string等等
AndroidManifest.xml:應用在手機上的配置,訪問網絡的允許等
Lesson 3: Start learning XML to create custom layouts
1. res/layout/main.xml 頁面佈局
<TextView //文字
android:layout_width="fill_parent" //寬度佔據屏幕寬度
android:layout_height="wrap_content" //高度和文字高度一樣
android:text="#string/hello"/> //內容使用value/strings.xml裏的hello的值
2. 可在strings.xml裏增加我們自定義的變量和變量值,這樣就可以在strings.xml裏面統一管理我們在佈局上使用的變量
Lesson 4: More XML and reference background
1. 增加按鈕button
android:textSize="25dp" //25px絕對大小,對於不同屏幕大小,會表現出不一樣的效果,而用dp爲單位,是與屏幕尺寸關聯的大小
android:orientation //設定水平排列或者垂直排列
LinearLayout //整個屏幕,改整個屏幕的背景,需要在LinearLayout的屬性裏改
android:background="@drawable/picture" //引用drawable裏的圖片時,只寫名字就行了,不用加後綴.png
Lesson 5: XML made EASY & Introduce Java
1. 圖形界面設計佈局,直接拖動按鈕等組件,屬性面板上可以調節組件的各種屬性,屬性面板可通過window->show view->others->常規->properties調出來
2. 使用id區別組件,使java程序引用時能夠識別引用的是哪一個組件
3. manifest.xml可以設置應用在手機上的圖標等等
4. new->android xml file 可以新建一個layout
Lesson 6: Getting Familiar with Java (intro)
1. 加聲音:新建res/raw文件夾,把聲音文件放在這個文件夾
2. 佈局上加圖片:imageView
3. Activity從onCreate開始
Lesson 7: Start creating the Splash Activity
1. Activity生命週期: android sdk網站/Reference
2. 編輯標籤頁右鍵->source->override methord, 可以自動創建重寫的函數
3. 創建線程Thread, finish()
Lesson 8: Get our app running with the while loop
1. 創建線程,線程中啓動新activity
Thread thread = new Thread() {
public void run() {
startActivity(new Intent("packageName.name"));
}
}
然後在Button的Listener裏啓動線程, thread.start(); ,這時會提示要將thread設置成final
2. 需要在manifest.xml中加上新的Activity,更改名稱和Intent的名稱
Lesson 9: Adding sound with MediaPlayer
1. MediaPlayer mpSplash = MediaPlayer.create(this, R.raw.noise);
mpSplash.start(); //開始音樂
mpSplash.release(); //停止音樂
mpSplash.pause(); //暫停音樂
2. 重寫一個Activity的onDestroy(), onPause(), onResume()
Lesson 10: Introduction to the BUTTON
1. 按鈕按下事件
Button button = (Button) findViewById(R.id.buttonId);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
);
2. Lesson 8, 加一個新的Activity