在Android的Bundle中存储和检索数组列表 [英] Store and retrieve array list in Bundle in Android

查看:115
本文介绍了在Android的Bundle中存储和检索数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 <$中存储和检索值的数组列表c $ c>捆绑包 在Android中?有示例吗?

How do I store and retrieve an array list of values in a Bundle in Android? Any examples?

推荐答案

如果数组列表中包含字符串,就可以考虑。

Lets take if you array list has strings in it.

ArrayList<String> al = new ArrayList<String>();
al.add("test1");
al.add("test2");
al.add("test3");

现在您可以按如下所示将其放入捆绑包:

Now you can put it into bundle as follows:

Bundle value= new Bundle();
value.putStringArrayList("temp1", al);

如果您有自己的对象类型而不是ArrayList中的 String,则需要序列化该ArrayList对象。

If you have your own object type instead of "String" in ArrayList then you need to serialize that ArrayList object.

这篇关于在Android的Bundle中存储和检索数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆