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