Android 學習之旅!(2)

kazehanaai發表於2015-05-21

早幾天因為學車,弄了幾天時間和精力過去,今天終於考過了(科目二,還是補考的...)嗯..不管這麼多了..今天又開始我的android 學習之旅!!

 

筆記:

platform-tools目錄下的檔案:

adb.exe : android debug bridge(android除錯橋)

  devices 列出所有連線裝置

  kill-server 殺掉 adb

  start-server 啟動 adb

dx.bat : 打包生成dex檔案

 

tools目錄下的檔案:

emulator.exe : 模擬器

 

專案檔案目錄下:

.setting  儲存配置資訊(eclipse)

assets  資產目錄(存放檔案,會打包到APK.例:圖片,資料庫...

bin  編譯後的檔案目錄

gen  (Generated Java File)(自動生成的檔案目錄)

  BuildConfig.java  適配資訊

  R.java  存放資源id的引用

Android x.x.x  (x.x.x版本號)

  android.jar(SDK)好吧,前面說的"夾包"是jar包...終於懂了..

project.properties  編譯版本

  target=android-x  (x版本號)

libs  支援的jar,會被新增到android depend目錄下

  android-support-v4.jar  (補錄API)

res  資源目錄

  drawable-xxxx(hdpi,ldpi,mdpi,xhdpi,xxhdpi...)  存放應用程式圖示  會自動生成id到R.java檔案

  layout

    activity_main.xml  (MVC中的View)   

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
View Code

       RelativeLayout(相對佈局)

      xmlns(名稱空間)

      Layout_width,Layout_height(控制元件的寬高)  match_parent(填充)

      wrap_content(包裹內容)

      centerHorizontal(水平居中)

      centerVertical(垂直居中)

      @(代表res,res又會編譯成R.java)  string(內部類)會在  res/values*/strings.xml 中有對應定義的字串

  AndroidMainfest.xml  (當前應用程式的清單檔案,程式的配置資訊={"啟動圖示","應用程式名稱","包名","版本號","..."})

<?xml version="1.0" encode="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.itheima.helloworld"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@strings/app_name"
    android:theme="@style/AppTheme" >
<activity
    android:name="com.itheima.helloworld.MainActivity"
    android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
View Code

    package="com.itheima.helloworld"  (手機應用依靠包名標識)

    android:versionCode="1",android:versionName="1.0"  (應用版本號)

    android:minSdkVersion="8"  (系統要求最低版本)  android:targetSdkVersion="17"  (系統最高版本?)

    android:icon="@drawable/ic_launcher"  (圖示)

    android:label="@string/app_name"  (應用程式名稱)

    android:theme="@style/AppTheme"  (應用程式樣式)

    <activity>應用程式介面  

    (在桌面生成圖示...)<intent-filter>額外的配置<action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />

    這裡我自己百度了一..

第一種情況:有MAIN,無LAUNCHER,程式列表中無圖示
原因:android.intent.category.LAUNCHER決定應用程式是否顯示在程式列表裡 
第二種情況:無MAIN,有LAUNCHER,程式列表中無圖示
原因:android.intent.action.MAIN決定應用程式最先啟動的Activity,如果沒有Main,則不知啟動哪個Activity,故也不會有圖示出現

  今天就這樣先吧..好多關鍵字都不懂啊..有點吃力

相關文章