android第一天:搭建基础环境

视频:善知堂Android   http://www.verycd.com/topics/2915940/

第一集:搭建环境

安装java,eclipse,sdk,google的插件.

第二集:程序结构

1.activity 指手机中的界面,相当于JFrame。

2.新建一个项目,其中main.xml是项目的布局

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
android:layout_width="fill_parent"
//占满父窗口
android:layout_width="match_parent"
//占满父窗口,和上面一样,推荐使用fill
android:layout_width="wrap_content"
//自动拉伸

3.使用res/values/strings.xml来进行赋值。

<string name="hello">Hello World, RestartActivity!</string>

调用

在main.xml中android:text="@string/hello" 

4.水平和垂直布局

android:orientation="vertical" 垂直布局
android:orientation="horizontal" 水平布局

5.R.java 相当于目录

当加入资源后,会自动在R.java中加入资源索引。

assets 也是放文件的,资源放在assets一样可以使用,但是不会更新R.java文件里

6.AndroidManifest.xml 清单文件

用来显示应用程序都有哪些内容。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="wan.test" 包名
    android:versionCode="1"  版本号
    android:versionName="1.0" > 版本名

    <uses-sdk android:minSdkVersion="10" /> 运行最低版本

    <application
        android:icon="@drawable/ic_launcher" 图标
        android:label="@string/app_name" >  应用名字
        <activity   目前只有一个activity
            android:name=".RestartActivity" 点的意思是当前包下的类
            android:label="@string/app_name" >   这个activity的名字
            <intent-filter> 意图所在activity,
                <action android:name="android.intent.action.MAIN" /> 这个是启动先执行的

                <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter>
        </activity>
    </application>

</manifest>

7.project.properties文件

其中包含

target=android-10

在版本10的开发环境中编写的。

8.res下新建文件

新建xml文件夹(xml文件),raw文件夹(二进制文件),menu文件夹(菜单文件)

 

今天结束。

posted on 2012-07-02 22:31  DON&#39;T PANIC  阅读(616)  评论(0编辑  收藏  举报

导航