intent几种传值数组、对象、集合(Array,Object,List)
1.Array
private ArrayList<String> checkList=new ArrayList<String>();Intent intent=new Intent(mytext.this,show.class);intent.putStringArrayListExtra("list", checkList);startActivity(intent);
调用
Intent intent=this.getIntent();ArrayList<String> list=intent.getStringArrayListExtra("list");ArrayList<HashMap<String,String>> mylist=new ArrayList<HashMap< String,String>>();///listview使用ListView listview=(ListView)findViewById(R.id.MyListView);for(int i=0;i<list.size();i++){HashMap<String,String> map=new HashMap<String,String>();map.put("ItemTitle", list.get(i).toString());mylist.add(map);}SimpleAdapter mSchedule=new SimpleAdapter(this,mylist,R.layout.show,new String[]{"ItemTitle","ItemTitle"},new int[]{R.id.ItemTitle,R.id.ItemTitle});listview.setAdapter(mSchedule);
2.对象、列表(object,List)
前面都一样,上遍文章已经讲解,这边补充一下,只讲一个Serializable的。。另一个Parcelable都差不多,各自实现各自的接口,调用的时候可以不用那么麻烦,真心不喜欢用Bundle ,挺多此一举的
改写
如果是List
List<Parking_Info> list=new ArrayList<Parking_Info>();//搜索结果集合
Intent intent=new Intent(LinkMap.this,MapList.class);intent.putExtra("list", (Serializable)list);startActivity(intent);
这边直接强制转化就行了,再接受的时候用(List<Parking_Info>) getIntent().getSerializable("list")就可以接受到List<Parking_Info>数据了
Listlist=(List)getIntent().getSerializableExtra("list");
调用起来倒也方便的
具体调用,遍历代码
@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.listmain);// List<Parking_Info> list=(List<Parking_Info>)getIntent().getSerializableExtra("list");//创建适配器SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.maplist,new String[]{"name","kongwei","code","addr"},new int[]{R.id.name,R.id.kongwei,R.id.code,R.id.addr});setListAdapter(adapter);// ListView listview=(ListView)findViewById(R.id.SearchList);// listview.setAdapter(adapter);};private List<Map<String, Object>> getData() { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); //获取参数 List<Parking_Info> mylist=(List<Parking_Info>)getIntent().getSerializableExtra("list");for(int i=0;i<mylist.size();i++){Map<String, Object> map = new HashMap<String, Object>();map.put("name",mylist.get(i).getPrk_name());map.put("kongwei","空位:"+mylist.get(i).getKongwei());map.put("code","收费:"+ mylist.get(i).getCode());map.put("addr","地址:"+mylist.get(i).getPrk_addr());list.add(map); // Toast.makeText(this, mylist.get(5).getPrk_name(), Toast.LENGTH_LONG).show();}return list;}
转载于:https://www.cnblogs.com/userbibi/archive/2012/03/29/2423202.html
intent几种传值数组、对象、集合(Array,Object,List)相关推荐
- javascript一种新的对象创建方式-Object.create()
1.Object.create() 是什么? Object.create(proto [, propertiesObject ]) 是E5中提出的一种新的对象创建方式,第一个参数是要继承的原型,如果不 ...
- 初识OpenGL (-)VAO顶点数组对象
1. VAO顶点数组对象(Vertex Array Object) 可以像顶点缓冲对象那样被绑定,任何随后的顶点属性调用都会储存在VAO中. 好处:当配置顶点属性指针时,你只需要将那些调用执行一次,之 ...
- JS中集合对象(Array、Map、Set)及类数组对象的使用与对比
JS中集合对象(Array.Map.Set)及类数组对象的使用与对比 在使用js编程的时候,常常会用到集合对象,集合对象其实是一种泛型,在js中没有明确的规定其内元素的类型,但在强类型语言譬如Java ...
- JavaScript:数组对象去重的几种方法
数组对象去重 元素是对象类型的数组的去重我这粗分为两类,一类是当数组中整个元素一样时的去重(这里说的一样是指元素对象中的属性和值都一样),第二类是,元素对象中的某一个属性的值一样时进行去重 // 通用 ...
- json 解析 转java对象数组对象数组对象_json字符串转java对象数组
需要引入json-lib-2.2-jdk15.jar和ezmorph-1.0.6.jar包 String itemStar = request.getParameter("itemStar& ...
- 初识 Python 科学计算库之 NumPy(创建多维数组对象)
文章目录 参考 描述 NumPy 特点 获取 导入 多维数组对象 np.array() np.asarray() 范围 随机 概览 np.random.randn() np.random.normal ...
- numpy ndarray 数组对象
https://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html 注意arange等函数生成的对象没有维度.既.shape属性,第二个数字是 ...
- 认识js函数对象(Function Object)
可以用function关键字定义一个函数,对于每个函数可以为其指定一个函数名,通过函数名来进行调用.这些都是代码给用户的印象,而在JavaScript解释执行的时候,实际上每个函数都是被维护为一个 ...
- Jackson:数组json字符串转对象集合(List)的两种方式
首先,创建个实体类Person import java.util.List;public class Person {private String name;private Integer age;p ...
最新文章
- idea_pyspark 环境配置
- $.ajax modal,使用bootstrap modal.load()加载的js,第二次modal显示的时候,js不生效?...
- (转)实现自己的http server
- python网络编程系列
- NSRunLoop 概述和原理
- 外卖小哥到底是一群什么样的人?答案超乎你想象
- (转)android studio工程编译不出来的一些error
- 银行如何构建反欺诈模型
- 基于单片机门电路测试
- VB中的“msgbox”函数各参数详解
- 整理的一些关于手机拍照技巧的内容
- telnet不是内部或外部命令解决方法
- 使用canvas实现对图片的翻转
- HuskyLens人工智能摄像头
- 山东大学软件学院项目实训第三周
- 铂电阻温度对应阻值计算方法
- 搞一个win7下能运行的免费财务软件 快马财务软件 v1.0
- Chrome浏览器占用内存过高解决办法
- 基于网络爬虫的技术实现
- 视频知识基础:什么是TS、PS流? .
热门文章
- BZOJ 2301 - Problem b(莫比乌斯反演+容斥)
- localStorage和sessionStorage的简单使用
- jdk1.7 String switch的实现
- 【iCore1S 双核心板_FPGA】例程十六:基于SPI的ARM与FPGA通信实验
- Java命名规范和代码风格
- 2015-05-31
- C#获取txt记事本内容,防止乱码情况
- lucene,lucene.net学习教程
- php求数组交集的自定义函数,php数组交集函数
- 多服务器 elk 搭建 [elasticsearch 7.0 ]