[英]How can I pass an arrayadapter to another activity?
Basically I'm making a battleships game with a messaging system. 基本上,我正在使用消息传递系统制作战舰游戏。 Therefore I've got another activity that the user can switch back and forth from.
因此,我进行了另一个活动,用户可以从中来回切换。 So if phone 1 sends a message to phone 2, phone 2 will add the message to an array adapter and then pass that to the new activity when the user goes to the message page.
因此,如果电话1向电话2发送消息,则电话2会将消息添加到阵列适配器,然后在用户转到消息页面时将其传递给新活动。 I hope this makes sense.
我希望这是有道理的。
How can I send my arrayadapter to another activity? 如何将我的arrayadapter发送到另一个活动? Is it something like
intent.putExtra(etc);
是否像
intent.putExtra(etc);
. 。 Do I need to save it to an arraylist and convert that to an array adapter in the new activity?
我是否需要将其保存到arraylist并将其转换为新活动中的阵列适配器?
I would say you should simply pass the underlying data to the other Activity, and have the arrayadapter reload the data. 我要说的是,您应该简单地将基础数据传递给另一个Activity,并让arrayadapter重新加载数据。 The ArrayAdapter is initialized with the context of the Activity you loaded it with.
ArrayAdapter会使用您加载它的Activity的上下文进行初始化。
The simplest you can do is make the ArrayAdapter serializable. 您最简单的方法是使ArrayAdapter可序列化。 Just implement the interface.
只需实现接口即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.