如何通过一个数组列表,从一个活动到另一个没有启动它 [英] How to pass an array list from one activity to another without starting it

查看:146
本文介绍了如何通过一个数组列表,从一个活动到另一个没有启动它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组列表中的活性

I have an activity which has an array list

ArrayList<String> array = new ArrayList<String>(); 

我想这个数组列表被传递到另一个活动在单击保存按钮时,但我不希望这样的活动启动...

i want this array list to be passed to another activity when a Save button is clicked, but i don't want that activity to start...

这通常code有助于启动一项活动

Usually this code helps in starting an activity

 public void onClick(View v) {
 if (v==Save)
            {
                Bundle bundle = new Bundle();
                bundle.putStringArrayList("DONE", activeURL);
                Intent myIntent = new Intent(Reader2.this, Aggregator.class);
                myIntent.putExtra("reader2", activeURL);
                startActivity(intent);

                }
}

但我只是想通过数组并开始另一项活动。 你能帮帮我吗? 先谢谢了。

but i just want to pass the array and start another activity. Can you please help me ? Thanks in advance.

推荐答案

您可以声明您ArrayList中为静态的这个样子,

You can declare you ArrayList as a static one like this,

public static ArrayList<String> array = new ArrayList<String>(); 

这样做,你可以从任何地方通过

By doing this you can access your ArrayList from anywhere by

activity_name.array;

在这里ACTIVITY_NAME是在声明静态的ArrayList活动或类

where activity_name is the activity or class in which you declare the static ArrayList

这篇关于如何通过一个数组列表,从一个活动到另一个没有启动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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