android 学习2—— Activity和Intent

1 多个Activity之间的关系:一个Activity跳到另一个用 startActivity(Intent intent)

2

 

Intent对象包含的信息  (Intent跟“请求”类似)

1 Component name  启动哪一个Activity

2 Action   指定另外一个Activity要做什么

3 Data    往另外一个Activity 传送什么数据

4 Category

5 Extras  键值对

6 Flags

 

先往main.xml添加Button

<Button

         android:id="@+id/myButton"

         android:layout_width="fill_parent"

         android:layout_height="vrap_content"

        />

 

//fill parent  满屏
//vrap_content 合适度
//android:layout_width  设置宽度
//android:layout_height 设置高度
//find ViewById(**)     取得控件
//adnroid:id="***" 定义控件的ID
//myTextVier.setText("**")设置文件控件的内含

 

 

 

取得一个控件

1.findViewByID(R.id.mytextview) 通过控件的ID来取得一个控件的
2.取各控件后一定要给控件转换一个数据类型
如:1.TextView mytextView=(textview)findviewbyid(R.id.mytestview)
     强制转换为testview类型
   2.Button mybutton=(button)findviewbyid(R.id.mybuttonview)
     强制转换为button类型

设置控件的内容:
 mytextview.settext("我的第一个文件控件")
 mybuttonview.settext("我的第一个Button控件")

 

  

 

Activity02

 

 

otherActivity

 

 

 

AndroidManifest.xml

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值