Android开发学习笔记-2 Activity-1 基础
1.Activity 的主要作用
Activity是控件的容器,类似于一个界面。
2.创建一个Activity
创建 Activity的要点
1.一个Activity就是一个类,并继承Activity
2.需要重写onCreate方法。
3.每一个Activity都需要在AndoridManifest.xml中进行配置
4.为Activity添加必要的控件,在layout文件夹中添加
3.在AndroidManifest.xml 文件中注册应用Activity的方法
4.在Activity中添加控件的方法
通过findViewById()方法获得控件,
例子:Button myButton = (Button)findViewById(R.id.myButton);
main.xml:
LinearLayout 线性布局
AbsoluteLayout 绝对布局
RelativeLayout 相对布局
TableLayout 表格布局
FrameLayout 帧布局