0105Activity+Intent

0105

1。

intent包含

component name

action

data

catagory

extras

flags

intent :就像请求?包含一些信息        intent可以启动activity 广播接收器,service等等

有很多activity,由intent中的component name 决定启动哪一个组件即哪一个activity

这个指定的activity应该做哪些动作就是由action决定的

Data就是一个activity向另一个activity传送了什么样子的数据

extras 在intent里面存放键值对 当intent在一个activity中调用令一个activity时

2.新创建另一个activity时 同时需要在layout中为他创建相应的布局文件new-other-android_layout_file

3value-string里面配值

<string name="other">OtherActivity</string> 这个string的名字叫other ,值为OtherActivity

4编写监听器类MyButtonListener,监听器是一个内部类,编写完监听器要把这个监听器捆绑在这个按钮上myButton.setOnClickListener(new MyButtonListener());

5每次写下一个Activity时都要在Android.Manifest.xml中进行注册

 <activity

            android:name="com.example.mars_activity.OtherActivity"

            android:lable="@string/other"

            />

只要点下这个按钮就会执行监听器中的方法

原文地址:https://www.cnblogs.com/kyxyes/p/2883720.html