Android 用Intent和Bundle传递参数
传递方:
//点击btn_sub传递 fieldHeight.getText()和 fieldWeight.getText()
private void setListeners()
{
btn_sub.setOnClickListener(calrBMI);
}
private OnClickListener calrBMI = new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("key_height", fieldHeight.getText().toString());
bundle.putString("key_weight", fieldWeight.getText().toString());
intent.setClass(ActivityMain.this,Report.class);
intent.putExtras(bundle);
startActivity(intent);
}
};
接收方:
Bundle bundle = new Bundle();
bundle = this.getIntent().getExtras();
double height = Double.parseDouble(bundle.getString("key_height"))/100;
double weight = Double.parseDouble(bundle.getString("key_weight"));
Android 用Intent和Bundle传递参数的更多相关文章
- Android,使用Intent或Bundle传递参数,跳转页面。
(1)使用Intent跳转页面: 第一个activity:MainActivity.java中: Intent myIntent = new Intent(); myIntent.putExtra(& ...
- 在Android中通过Intent使用Bundle传递对象
IntentBundle传递对象SerializableParcelable Android开发中有时需要在应用中或进程间传递对象,下面详细介绍Intent使用Bundle传递对象的方法.被传递的对象 ...
- 17_Android中Broadcast详解(有序广播,无序广播)最终广播,Bundle传递参数,传递参数的时候指定权限
1 Broadcast是Android中的四大组件之一,他的用途很大,比如系统的一些广播:电量低.开机.锁屏等一些操作都会发送一个广播. 2 广播被分为两种不同的类型:"普通广播( ...
- 【转】Android中如何使用Bundle传递对象[使用Serializable或者Parcelable] -- 不错
原文网址:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2012/1211/694.html Android中Bundle类的作用 Bun ...
- Android 笔记 Intent and Bundle day7
学习了Intent与Bundle的使用,进行应用中的交互 package com.example.intent; import android.app.Activity; import android ...
- html5页面与android页面之间通过url传递参数
html5页面与android页面之间可以通过url传递参数,android将参数放在htm5的url ?后面,js获取url ?号后面的参数. 方法一: <scrīpt> /* 用途 ...
- Activity 间 bundle 传递参数
activity_main.xml <TableLayout xmlns:android="http://schemas.android.com/apk/res/android&quo ...
- Android学习总结——Activity之间传递参数
核心内容:一.在 Activity 之间传递简单数据二.在 Activity 之间传递复杂数据 三.在 Activity 之间传递自定义值对象 软件环境:Android Studio 一.在 ...
- 跳转页面,传递参数——android
android 跳转页面并传递对象(实体类)——项目中是集港收货类 网上资料:两种传递方法Serializable,parcelable 优劣比较:Serializable数据更持久化,网络传输或数据 ...
随机推荐
- How Indexes Are Stored
reference: http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm#CHDJGADJ 当创建索引的时候,Oracl ...
- iOS Core Animation学习总结(2)--实现自定义图层
一. 创建图层继承于CALayer,并在子类实现drawInContext方法 @interface CTLayer : CALayer @end @implementation CTLayer -( ...
- asp.net MVC URL路由入门指南
asp.net MVC 的URL路由是一个非常强大的功能,而且有个优点:强大单不复杂.然而,目前我在网上看到的相关资料,却都仅仅提供一些示例,仅通过这些示例,初学者基本上不可能明白为什么要这么配置,更 ...
- ZOJ 2392 The Counting Problem(模拟)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1368 题目大意:计算从S到T中所有的数,其中0,1,2,3,4,5, ...
- c++实现类似Common Lisp的多参数加法和比较
在CL里我们可以这样: $ sbcl * (+ 1 2 3) 6 * (< 1 2 3) T * (< 2 3 1) NIL * 从简单的方面看, CL的+和<就是一个接收多参数的函 ...
- linux系统使用密钥登录设置
使用密钥登录linux的操作步骤(使用putty): 1.用putty远程登录linux服务器,然后使用puttygen生成密钥,将生成的密钥保存,保存私钥将公钥复制保存到linux服务器的autho ...
- Linux中的时间和时间管理
Coordinated Universal Time(UTC):协调世界时,又称为世界标准时间,也就是大家所熟知的格林威治标准时间(Greenwich Mean Time,GMT).比如,中国内地的时 ...
- nginx 常用的 URL 重写方法
转自:http://www.jbxue.com/article/4727.html Nginx中一些常用的URL 重写方法介绍,有需要的朋友可以参考下.url重写应该不陌生,不管是SEO URL 伪静 ...
- 【BZOJ】1012: [JSOI2008]最大数maxnumber 树状数组求区间最值
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1012 题意:维护一个数列,开始时没有数值,之后会有两种操作, Q L :查询数列末 ...
- 【mapping】 springmvc的注解mapping无法生效的问题
springmvc 始终无法加载 注解 map, 解决办法 八月 11, 2015 8:24:42 下午 org.springframework.web.servlet.DispatcherServl ...