的Java / Android的ArrayList的不同活动 [英] Java / Android ArrayList in different Activity

查看:108
本文介绍了的Java / Android的ArrayList的不同活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个ArrayList在Android上的另一个活动工作。一切都很好。在创建arrray名单,但是,我不能得到意向的工作。

I'm trying to get an Arraylist to work in another Activity on Android. All is well. The arrray list is created, however, I cannot get Intent to work.

什么办法就是那里得到一个ArrayList另一个变量?

What way is there to get an arraylist to another variable?

下面是code我使用生成的ArrayList

Here is the code I'm using to generate the arrayList:

public List<Contact> getAllContacts() {
List<Contact> ContactpList = new ArrayList<Contact>();

我将如何去制作此ArrayList可在我的其他的活动?

How will I go about making this arraylist available in my other activities?

推荐答案

这是你的活动是你有数组列表中右键:

This is your activity were you have array list Right:

public List<Contact> getAllContacts() {
List<Contact> ContactpList = new ArrayList<Contact>();

现在当u调用另一个活动然后发送数组对象是这样的:

now when u call another activity then send the array object like this:

Intent intent = new Intent(youractivity.this,youractivity.class);
intent.putExtra("ContactpList ", ContactpList );
startActivity(intent);

现在得到这个数组中,你都呼吁并且是ü希望得到阵列的活动:

now get this array in the activity which you have called and were u want to get the array:

ArrayList<String> resultArray = getIntent().getStringArrayListExtra("ContactpList ");

希望这是你的工作。

Hope it is work for you.

这篇关于的Java / Android的ArrayList的不同活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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