How to pass ArrayList>from one activity to another

前端 未结 4 1182
你的背包
你的背包 2020-11-30 02:39

How i can pass Array List from one Activity to another my array list is shown as follows

ArrayList>
4条回答
  •  萌比男神i
    2020-11-30 03:27

    You can use a Bundle to pass elements from one Activity to another.

    Check this out: http://developer.android.com/reference/android/os/Bundle.html

    You create the Bundle, put it into the Intent, and then on the new activity, you get it and extract the elements you need.

    It goes like this:

    Bundle b = new Bundle();
    String s = "hello";
    b.putString("example", s);
    intent.putExtras(b);
    

    and then on the new activity:

    Bundle b = this.getIntent().getExtras(); 
    String s = b.getString("example");
    

提交回复
热议问题