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的更多相关文章

  1. 在Activity之间如何传递数据,请尽可能说出你所知道的传递数据的方法,并详细描述其实现过程。

    在Activity之间如何传递数据,请尽可能说出你所知道的传递数据的方法,并详细描述其实现过程. 答案:可以通过Intent对象.静态变量.剪切板和全局对象进行数据传递,具体的数据传递方法如下. 1. ...

  2. [Android]Activity跳转传递任意类型的数据、Activity为SingleTask时代替StartActivityForResult的解决方案

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/4389674.html 需求:在ActivityA跳转到Acti ...

  3. Android 之 使用 Intent 在活动间传递数据

    •前言 继上次学习了<通过 Intent 完成点击按钮实现页面跳转>后,我们知道了如何通过 Intent 实现页面跳转: Intent 除了可以实现页面跳转外,还可以在跳转的时候传递数据: ...

  4. Android Activity和Fragment传递数据

    1.Activity与Activity传递数据 UserLoginActivity.java: Intent welcomePage = new Intent(); Bundle dataBundle ...

  5. 四大组件之Activity——组件间传递数据的4种常用方法

    在Android中传递数据的方法非常多,本次介绍4中比较常用的数据传递方法: 通过Intent/Bundle传递数据 通过静态变量(static)传递数据:需构建跳转页面相应静态变量http://bl ...

  6. Android基础知识04—Activity活动之间传递数据

    ------活动之间传递数据------ 向下一个活动传递数据: Intent中提供了一系列的putExtra()方法,可以把数据暂存到Intent中,启动另一个活动的时候就可以取出来. 代码: (存 ...

  7. android传递数据bundle封装传递map对象

    android开发默认情况下,通过Bundle bundle=new Bundle();传递值是不能直接传递map对象的,解决办法: 第一步:封装自己的map,实现序列化即可 ? 1 2 3 4 5 ...

  8. 【Android】Intent中使用Extra传递数据

    传值方法一 Intent intent = new Intent(); Bundle bundle = new Bundle(); //该类用作携带数据 bundle.putString(" ...

  9. android 入门-Service实时向Activity通过BroadcastReceiver传递数据

    引文: http://www.cnblogs.com/linjiqin/p/3147764.html <RelativeLayout xmlns:android="http://sch ...

随机推荐

  1. java reflect反射调用方法invoke

    类定义 package Reflect; public class MyTest { public int a; public static int b; public static final in ...

  2. Intellij IDEA编辑golang时无法加载系统GOPATH变量

    问题: 编译go项目时,报找不到包.从日志看,GOPATH与系统设置的不一致. 如何解决:系统的gopath路径,加到Project libraries中 参考:https://segmentfaul ...

  3. 我的母校zbvc试做

    一.观察分析页面布局 可以从上至下分为6大部分 logo栏 menu菜单栏 slide幻灯片 news新闻区域 other其他 bottom底部 二.logo 分为三部分 ①左侧logo ②中间log ...

  4. SpringBoot配置定时任务的两种方式

    一.导入相关的jar包 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  5. spring-mvc.xml与spring-mybatis.xml配置文件中命名空间问题

    首先贴出配置文件: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="htt ...

  6. aaad

    I remember the wonderful moment you appeared before me, like a fleeting vision, like a genius of pur ...

  7. c中计时函数 clock()

    #include<time.h> int main() { // ... .. // .... printf("Time used = %.2lf\n",(double ...

  8. 尚硅谷springboot学习23-SpringMVC配置

    1. Spring MVC auto-configuration 以下是SpringBoot对SpringMVC的默认配置:(WebMvcAutoConfiguration) Inclusion of ...

  9. DNS协议工作过程;DNS的安全隐患

    DNS协议工作过程   下面以域名为m.xyz.com的主机欲通过另一个主机的域名y.abc.com的IP地址为例,简述DNS协议过程. 主机m.xyz.com先向其本地服务器dns.xyz.com进 ...

  10. 14.连接池.md

    目录 连接池定义 常用开源连接池: DBCP: C3P0 连接池定义 使用统一的规范:javax.sql.DataSource实现统一编程 常用开源连接池: DBCP:tomcat C3P0:hibe ...