捆绑的ArrayList&LT

捆绑的ArrayList&LT

本文介绍了捆绑的ArrayList< ArrayList的<整数GT;>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过一个的ArrayList< ArrayList的<整数GT;>地板通过捆绑其他活动?

感谢


解决方案

Unfortunetly not.

If you would have ArrayList without nested it will work with putIntegerArrayList(key, value) and getIntegerArrayList(key).

But there is for sure another approach(es).I will explain you one possible way.

You can create class that will implement Serializable interface and in this class just create field and appropriate getter. I will give you basic example. Then you will pass Serializable through Activities.

public class DataHelper implements Serializable {

   private ArrayList<ArrayList<Integer>> floors;

   public DataHelper(ArrayList<ArrayList<Integer>> floors) {
      this.floors = floors;
   }

   public ArrayList<ArrayList<Integer>> getList() {
      return this.floors;
   }
}

Save it to Bundle:

Bundle b = new Bundle();
b.putSerializable("floors", new DataHelper(floors));

and retrieve in target Activity:

getIntent().getExtras().getSerializable("floors");

这篇关于捆绑的ArrayList&LT; ArrayList的&LT;整数GT;&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:22