如何使用我创建的自定义变量类型在活动之间发送数据?我已经检查并且“putExtra/putExtras”选项不允许我发送我的自定义变量,它只允许 string/boolean/int/....
问问题
423 次
2 回答
1
使用 Bundle 并使您的自定义变量可序列化。
Bundle bundle = new Bundle();
bundle.putSerializable("key", CustomVariableObject());
intent.putExtras(bundle);
于 2016-04-29T00:33:34.627 回答
0
你需要序列化你的对象
intent.putExtra("MyData", data);
getIntent().getSerializableExtra("MyData");
你可以在这篇文章中看到更多信息
于 2016-04-29T00:33:53.697 回答