0

I have a simplest object, and for this I use parcelable. But this object is more complex, have multidimensional array and I really don't know how to write the parcelable methods:

public class PointSystem 
{
    private int point;
    private boolean [] vec1;
    private HashSet <Integer> hs1;
    private int [][]    vecMap;
}

I removed the other istance variable of the same type and the methods so the code is more readable. I tried with serializable but I don't know how to cast from the other intent the serializable that I get to array [][].

How could I make this object parcelable? Or there're other way to pass this object to another intent?

4

1 回答 1

1
  1. 首先,您说您尝试将获得的可序列化转换为 array[][],您是否尝试将此对象的所有成员作为单独的附加项传递?为什么不序列化整个 PointSystem 对象并将其作为额外对象传递。然后,当您尝试接收它时:

    PointSystem p = (PointSystem) getIntent().getSerializableExtra("Extra_Name");
    int[][] vecMap = p.vecMap;
    
  2. 使用 Parcelable 的一个很好的例子可以在这个答案中找到

于 2013-06-09T19:02:09.810 回答