[英]Passing 2D array of objects to another Activity
我正在尝试传递(对象)数组,不幸的是(据我所知),可序列化的捆绑包不适用于自定义对象。
我有上课座位:
public class seat{
boolean state;
int Seatb;
}
这是第一个活动的代码:
seat [][] arrseat=new seat[20][20];
Intent intent = new Intent(this, MainActivity2.class);
intent.putExtra("data", arrseat);
startActivity(intent);
第二项活动:
seat [][] obseat=new seat[20][20];
Intent intent = getIntent();
obseat=intent.?
我找不到从意图中获取数组的方法
数组是可序列化的,因此可以使用putSerializable。 投入价值
Intent i = new Intent(this, AnotherClass.class);
Bundle b = new Bundle();
b.putSerializable("arr", seat);
i.putExtras(b);
获得价值
seat[][] arrseat = (seat[][]) bundle.getSerializable("arr");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.