》Android启动说明
1. 运行apk
2. 系统通过文件刘技术与xml解析技术,取出AndroidManifest.xml的内容
3. 系统根据package = “com.fs.act”与android :name “MaiActivity”得一个类com.fs.act.MainActivity,-------入口类
4. 系统穿件入口类的对象(反射技术),并使用Activity引用类型变量来指向它;
5. 系统调用MainActivity类中的onCreate函数----------入口函数
Actvity.onCreate(.....);
》xml文件配置
通过xml文件配置AndroidMainfest.xml文件,系统自动穿件对象
<LinearLayout ……/>不嵌套、<LinearLayout……</LinearLayout>嵌套的
<LinearLayout>为线性布局容器
<Button>
<TextView>
<EditorText>
....
属性配置:android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="btn2"
……
》界面设计:
代码中得到View两种方法:
1.手动创建View对象
2.手动通过布局文件xml得到View对象
》创建监听器:
1. 创建监听器接口 :private OnClickListener listener = new OnClickListener(),并重写onClick(View v)
2. 获得Button、LINEARlAYOUT等监听对象的**:Button enter = (Button)this.findViewById(R.id.enter);
3. 通过Botton对象enter.setOnClickListener(监听器对象)开启监听;
Intent intent = new Intent();意图
intent.setClass(...);//Context
this.startActivity(intent)
Intent可以装东西、装到哪里
配置AndroidMainfest.xml文件;
<activity android:name=".TwoActivity"
android:label="two">
</activity>