Intent Activity跳转 传递数据 Bundle
1、普通跳转:
Intent intent=new Intent();
intent.setClass(MainActivity.this,NewActivity.class);
//新建一个Intent,使用setClass方法设置跳转的哪个界面
startActivity(intent);
2、数据传递
Bundle data=new Bundle();
//创建了一个Bundle对象用来存储在两个Activity之间传递的数据
data.putString("website","cnblogs.com/hjw1");
data.putString("name","环家伟");
data.putInt("age",20);
//添加进Bundle对象里面两个String类型的数据和一个int类型的数据
Intent gotoAnother=new Intent(MainActivity.this,Main2Activity.class);
//创建了一个从MainActivity跳转到Main2Activity的Intent
gotoAnother.putExtras(data);
//将存储了数据的Bundle对象put进Intent里面
startActivity(gotoAnother);
//开始跳转
Bundle receive=getIntent().getExtras();
//得到随Intent传递过来的Bundle对象
String name=receive.getString("name");
String website=receive.getString("website");
int age=receive.getInt("age");
Intent Activity跳转 传递数据 Bundle的更多相关文章
- 在Activity之间如何传递数据,请尽可能说出你所知道的传递数据的方法,并详细描述其实现过程。
在Activity之间如何传递数据,请尽可能说出你所知道的传递数据的方法,并详细描述其实现过程. 答案:可以通过Intent对象.静态变量.剪切板和全局对象进行数据传递,具体的数据传递方法如下. 1. ...
- [Android]Activity跳转传递任意类型的数据、Activity为SingleTask时代替StartActivityForResult的解决方案
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/4389674.html 需求:在ActivityA跳转到Acti ...
- Android 之 使用 Intent 在活动间传递数据
•前言 继上次学习了<通过 Intent 完成点击按钮实现页面跳转>后,我们知道了如何通过 Intent 实现页面跳转: Intent 除了可以实现页面跳转外,还可以在跳转的时候传递数据: ...
- Android Activity和Fragment传递数据
1.Activity与Activity传递数据 UserLoginActivity.java: Intent welcomePage = new Intent(); Bundle dataBundle ...
- 四大组件之Activity——组件间传递数据的4种常用方法
在Android中传递数据的方法非常多,本次介绍4中比较常用的数据传递方法: 通过Intent/Bundle传递数据 通过静态变量(static)传递数据:需构建跳转页面相应静态变量http://bl ...
- Android基础知识04—Activity活动之间传递数据
------活动之间传递数据------ 向下一个活动传递数据: Intent中提供了一系列的putExtra()方法,可以把数据暂存到Intent中,启动另一个活动的时候就可以取出来. 代码: (存 ...
- android传递数据bundle封装传递map对象
android开发默认情况下,通过Bundle bundle=new Bundle();传递值是不能直接传递map对象的,解决办法: 第一步:封装自己的map,实现序列化即可 ? 1 2 3 4 5 ...
- 【Android】Intent中使用Extra传递数据
传值方法一 Intent intent = new Intent(); Bundle bundle = new Bundle(); //该类用作携带数据 bundle.putString(" ...
- android 入门-Service实时向Activity通过BroadcastReceiver传递数据
引文: http://www.cnblogs.com/linjiqin/p/3147764.html <RelativeLayout xmlns:android="http://sch ...
随机推荐
- leetcode1024
class Solution(object): def videoStitching(self, clips: 'List[List[int]]', T: int) -> int: li = s ...
- 使用cuteFTP与虚拟机交互文件---安装ftp服务
安装ftp服务,以便在Windows中使用cuteFTP与虚拟机交互文件,使用sudo apt-get install vsftpd 安装完后,打开/etc/vsftpd.conf文件,去掉local ...
- 【JEECG技术文档】JEECG高级查询构造器使用说明
功能介绍 高级查询构造器支持主子表联合查询,查询出更精确的数据. 要使用高级查询构造器需要完成以下步骤: 1. 在高级查询管理配置主子表信息. 2. 配置完后在JSP页面DataGrid标签上添加 ...
- 希尔&计数&基数排序
一.希尔排序 shell_sort def insert_sort_gap(li,gap): for i in range(gap,len(li)): tem = li[i] # 要插入的数 j = ...
- linux查询硬件信息
硬件信息查询 sudo dmidecode -t baseboard
- English Pronunciation Analysis | Advanced English Conversation
English Pronunciation Analysis | Advanced English Conversation Share Tweet Share Tagged With: Ben Fr ...
- Linux find命令使用方法
Linux中find命令用来在指定目录下查找文件.通过组合不同参数可以在linux系统中快速查找需要的文件或目录. find命令语法 格式:find pathname -options [ -pr ...
- delphi 域名转ip并判断ip是否可以联通
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- C# HttpWebRequest 错误总结
1.form data 需要编码!!! byte[] data = new ASCIIEncoding().GetBytes("pattern=0&wwid=古兴越&good ...
- 学JS的心路历程-Promise(二)
昨天有说到Promise的创建以及then的用法,今天我们来看错误处理. then onRejected 我们昨天有提到说,then两个函式参数,onFulfilled和onRejected,而onR ...