Android學(xué)習(xí)筆記總結(jié)初學(xué)者必看

    時(shí)間:2024-07-24 08:08:49 學(xué)習(xí)總結(jié) 我要投稿
    • 相關(guān)推薦

    Android學(xué)習(xí)筆記總結(jié)初學(xué)者必看

      Android學(xué)習(xí)筆記總結(jié)初學(xué)者必看

    Android學(xué)習(xí)筆記總結(jié)初學(xué)者必看

      Android學(xué)習(xí)筆記總結(jié)

      第一步:

      Android(1) - 在 Windows 下搭建 Android 開發(fā)環(huán)境,以及 Hello World 程序

      搭建 Android 的開發(fā)環(huán)境,以及寫一個(gè)簡單的示例程序

      在 Windows 下搭建 Android 開發(fā)環(huán)境 Android 項(xiàng)目的目錄結(jié)構(gòu)說明 寫一個(gè)簡單的 Hello World 程序

      一、在 Windows 下搭建 Android 開發(fā)環(huán)境

      1、安裝 JDK (Java Development Kit)

      http://download.java.net/jdk6/

      2、安裝 Android SDK

      http://developer.android.com/sdk

      3、安裝 Eclipse

      /android/eclipse/ ,然后安裝 ADT(Android Development Tools)

      5、新建 Android 項(xiàng)目

      "New" -> Android Project,Project Name - 項(xiàng)目名稱;Build Target - 編譯項(xiàng)目的 SDK 版本;Application name - 程序名稱;Package name - 包名;Min SDK Version - 程序所支持的最低 SDK 版本代號(2 對應(yīng) 1.1,3 對應(yīng) 1.5,4 對應(yīng) 1.6)

      6、運(yùn)行 Android 項(xiàng)目

      打開菜單 "Run" -> "Run Configurations" -> New launch configuration,設(shè)置啟動(dòng)項(xiàng)目名稱,在 Android 選項(xiàng)卡中選擇啟動(dòng)項(xiàng)目,在 Target 選項(xiàng)卡中設(shè)置模擬器

      7、創(chuàng)建/使用模擬 SD 卡

      創(chuàng)建 SD 卡,運(yùn)行類似如下命令:mksdcard -l sdcard 512M d:androidsdcard.img

      模擬器中使用 SD 卡,在項(xiàng)目配置的 Target 選項(xiàng)卡的 "Additional Emulator Command Line Options" 框中輸入類似如下參數(shù):-sdcard d:androidsdcard.img

      8、配置模擬器

      運(yùn)行類似如下命令:android create avd --name android15 --target 2。或者直接在菜單 "Window" -> "Android AVD Manager" 中配置模擬器

      9、瀏覽模擬 SD 卡中的內(nèi)容

      調(diào)試程序,在 DDMS 中選擇 "File Explorer" ,在其中的 sdcard 目錄下就是模擬 SD 卡中的內(nèi)容

      10、查看日志 LogCat

      Window -> Show View -> Other -> Android -> LogCat

      11、在模擬器中安裝/卸載 apk

      安裝 apk 運(yùn)行類似如下命令:adb install name.apk;卸載 apk 運(yùn)行類似如下命令:adb uninstall packagename(注:這里的參數(shù)是需要卸載的包名)

      12、反編譯 Android 程序

      解壓 apk 文件,取出其中的 classes.dex 文件,運(yùn)行類似如下命令:dexdump.exe -d classes.dex > dump.txt(其意思是將 classes.dex dump 出來,并將反編譯后的代碼保存到指定的文本文件中)

      13、人品不好是出現(xiàn)的某些錯(cuò)誤的解決辦法

      如果出現(xiàn)類似如下的錯(cuò)誤等

      no classfiles specified

      Conversion to Dalvik format failed with error 1

      解決辦法:Project -> Clean

      出現(xiàn) Android SDK Content Loader 60% (一直卡在 60%)

      解決辦法:Project -> 去掉 Build Automatically 前面的勾

      14、查看 SDK 源代碼

      先想辦法搞到源代碼,如這個(gè)地址 /android.asp ,然后將其解壓到 SDK 根路徑下的 sources 文件夾內(nèi)即可

      二、Android 項(xiàng)目的目錄結(jié)構(gòu)

      1、src - 用于放置源程序

      2、gen - 自動(dòng)生成 R.java 文件,用于引用資源文件(即 res 目錄下的數(shù)據(jù))

      3、assets - 用于放置原始文件,Android 不會(huì)對此目錄下的文件做任何處理,這是其與 res 目錄不同的地方

      4、res/drawable - 用于放置圖片之類的資源;res/layout - 用于放置布局用的 xml 文件;res/values - 用于放置一些常量數(shù)據(jù)

      5、AndroidManifest.xml - Android 程序的清單文件,相當(dāng)于配置文件,配置應(yīng)用程序名稱、圖標(biāo)、Activity、Service、Receiver等

      三、Hello World 程序

      1、res/layout/main.xml 代碼

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"

      android:layout_width="fill_parent"

      android:layout_height="fill_parent"

      android:id="@+id/layout"

      >

      <TextView

      android:layout_width="fill_parent"

      android:layout_height="wrap_content"

      android:text="@string/hello"

      />

      <TextView

      android:layout_width="fill_parent"

      android:layout_height="wrap_content"

      android:id="@+id/txt"

      />

      2、res/values/strings.xml

      代碼

      layout 直接調(diào)用 values 中的字符串

      編程方式調(diào)用 values 中的字符串

      webabcd_hello

      3、res/drawable 目錄下放置一個(gè)名為 icon.png 的圖片文件

      4、AndroidManifest.xml

      代碼

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

      package="com.webabcd.hello"

      android:versionCode="1"

      android:versionName="1.0">

      <activity android:name=".Main"

      android:label="@string/app_name">

      5、Main.java 代碼

      package com.webabcd.hello;

      import android.app.Activity;

      import android.os.Bundle;

      import android.widget.LinearLayout;

      import android.widget.TextView;

      public class Main extends Activity {

      /** Called when the activity is first created. */

      @Override

      public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      // 將指定的布局文件作為 Activity 所顯示的內(nèi)容

      setContentView(R.layout.main);

      // 動(dòng)態(tài)地在指定的容器控件上添加新的控件

      TextView txt = new TextView(this);

      txt.setText("動(dòng)態(tài)添加控件");

      // setContentView(txt);

      ((LinearLayout)this.findViewById(R.id.layout)).addView(txt);

      // 引用資源文件內(nèi)的內(nèi)容作為輸出內(nèi)容

      TextView txt1 = (TextView)this.findViewById(R.id.txt);

      txt1.setText(this.getString(R.string.hello2));

      }

      }

      Android(2) - 布局(Layout)和菜單(Menu)

      介紹

      在 Android 中各種布局的應(yīng)用,以及菜單效果的實(shí)現(xiàn)

      ? 各種布局方式的應(yīng)用,F(xiàn)rameLayout, LinearLayout, TableLayout, AbsoluteLayout, RelativeLayout

      ?

      為指定元素配置上下文菜單,為應(yīng)用程序配置選項(xiàng)菜單,以及多級菜單的實(shí)現(xiàn)

      1、各種布局方式的演示 res/layout/main.xml 代碼

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:gravity="right"

      android:layout_width="fill_parent" android:layout_height="fill_parent">

      <FrameLayout android:layout_height="wrap_content"

      android:layout_width="fill_parent">

      <TextView android:layout_width="wrap_content"

      android:layout_height="wrap_content" android:text="FrameLayout">

      <TextView android:layout_width="wrap_content"

      android:layout_height="wrap_content" android:text="Frame Layout">

      <TextView android:layout_width="wrap_content"

      android:layout_height="wrap_content" android:text="@string/hello" />

      <!--

      

    【Android學(xué)習(xí)筆記總結(jié)初學(xué)者必看】相關(guān)文章:

    android程序員試用期工作總結(jié)08-02

    Android實(shí)習(xí)生求職信范文07-06

    學(xué)習(xí)的總結(jié)11-29

    學(xué)習(xí)總結(jié)05-24

    學(xué)習(xí)師德師風(fēng)學(xué)習(xí)總結(jié)06-11

    師德學(xué)習(xí)總結(jié)10-29

    學(xué)習(xí)個(gè)人總結(jié)08-30

    畢業(yè)學(xué)習(xí)總結(jié)06-11

    關(guān)于學(xué)習(xí)總結(jié)10-08

    禮儀的學(xué)習(xí)總結(jié)07-17

    国产一级a爱做免费播放_91揄拍久久久久无码免费_欧美视频在线播放精品a_亚洲成色在线综合网站免费

      亚洲国产综合性网站 | 精品亚洲成AV片在线观看 | 亚洲日本香蕉观看观视频 | 亚洲区国产精品高清 | 亚洲乱码国产乱码精品精在线观看 | 香港三级日本三级a视频 |