android传递数据bundle封装传递map对象
android开发默认情况下,通过Bundle bundle=new Bundle();传递值是不能直接传递map对象的,解决办法:
第一步:封装自己的map,实现序列化即可
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/** * 序列化map供Bundle传递map使用 * Created on 13-12-9. */public class SerializableMap implements Serializable { private Map<String,Object> map; public Map<String, Object> getMap() { return map; } public void setMap(Map<String, Object> map) { this.map = map; }} |
第二步:传递数据:
|
1
2
3
4
5
6
7
|
Intent intent=new Intent(ListViewActivity.this,UpdateWatchActivity.class); //传递数据 final SerializableMap myMap=new SerializableMap(); myMap.setMap(map);//将map数据添加到封装的myMap<span></span>中 Bundle bundle=new Bundle(); bundle.putSerializable("map", myMap); intent.putExtras(bundle); |
第三步:接收数据:
|
1
2
|
Bundle bundle = getIntent().getExtras(); SerializableMap serializableMap = (SerializableMap) bundle.get("map"); |
到此数据就能在通过map传递和使用了。
android传递数据bundle封装传递map对象的更多相关文章
- Android基础 -- Activity之间传递数据(bitmap和map对象)
原文:http://blog.csdn.net/xueerfei008/article/details/23046341 做项目的时候需要用到在2个activity之间传递一些数据,之前做的都是些字符 ...
- POI 导入excel数据自动封装成model对象--代码
所有的代码如下: import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; ...
- Intent Activity跳转 传递数据 Bundle
1.普通跳转: Intent intent=new Intent(); intent.setClass(MainActivity.this,NewActivity.class); //新建一个Inte ...
- POI 导入excel数据自动封装成model对象--介绍
1.项目开发中,导入输入应该是常用的基本功能.我们经常会使用excel将数据导入到数据库,在导入之前必须得将excel数据转换成javaBean对象 2.由于此功能经常使用,所以开发此工具类方便日后轻 ...
- POI 导入excel数据自动封装成model对象--代码分析
上完代码后,对代码进行主要的分析: 1.主要使用反射api将数数据注入javabean对象 2.代码中的日志信息级别为debug级别 3.获取ExcelImport对象后需要调用init()方法初始化 ...
- 【转】Android 之最新最全的Intent传递数据方法
原文地址:https://www.jianshu.com/p/1169dba99261 intent传递数据 为什么要和intent单独拿出来讲,因为Intent传递数据也是非常重要的 一.简单的传递 ...
- Android 使用剪切板传递数据
使用剪切板传递数据,可以传递简单的数据,也可以传递可序列化的对象. 首先来个简单点吧. 首先在,mainActivity.xml文件中加入一个button按钮 private Button butto ...
- Android学习之Intent传递数据
Intent在Activity中的作用主要是有两个: 1.启动目标Activity 2.传递数据 Intent在传递数据时分两种情况:向下一个Activity传递数据和从下一个Activity返回数据 ...
- Android Activity间跳转与传递数据
1 概述 Activity之间的跳转主要使用 startActivity(Intent intent); startActivityForResult(Intent intent,int reques ...
随机推荐
- Redis-消息
Redis 发布订阅(实际开发不使用) Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. Redis 客户端可以订阅任意数量的频道. 下图 ...
- spring简要回顾
spring内容 spring容器: @Repository @Service @Controller @Component <bean id="类名首字母小写">默认 ...
- 一些基础但有趣的shell脚本
一.打印9*9乘法表 #!/bin/bash for i in `seq 9` do for j in `seq $i` do echo -n "$i*$j=$[i*j]" don ...
- Could not find result map com.youotech.tl_cons_credit_rating.entity.Result
后端报错如下: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.yo ...
- KafKa集群安装、配置
一.事前准备 1.kafka官网:http://kafka.apache.org/downloads. 2.选择使用版本下载. 3.kafka集群环境准备:(linux) 192.168.145.12 ...
- 【Math】高数-一个有趣的旋转体体积与面积
Go confidently in the direction of your dreams. Live the life you've imagined. 题目 设曲线 \(y = \tfrac{1 ...
- linux 命令——screen
最近遇到一个东西aria2,这个玩意,这个是啥呢?Aria2是一个轻量级Linux下载软件,支持HTTP/HTTPS, FTP, SFTP, BitTorrent和磁力链接(官方版),公司系统插件配套 ...
- Hyperledger Explorer
简介 Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open source utility to ...
- 吴裕雄 PYTHON 神经网络——TENSORFLOW 单隐藏层自编码器设计处理MNIST手写数字数据集并使用TensorBord描绘神经网络数据
import os import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow ...
- 安装pyhanlp
安装pyhanlp pyhanlp是java写的,外层封装了python. 对于新手,在使用的时候稍有难度. 1. 下载源码 https://github.com/hankcs/pyhanlp git ...