如何将 ArrayAdapter 发送到 ListActivity
我想知道如何将我正在填写一个活动的 ArrayAdapter 发送到 ListActivity 显示它。
该程序本身搜索周围的蓝牙设备并用其名称填充 ArrayAdapter,然后我想将创建的列表发送到 ListActivity 以便用户可以选择一个。
谢谢
i would like to know how to send an ArrayAdapter that i'm filling in one activity, to a ListActivity display it.
The program itself searches for bluetooth devices around and fills the ArrayAdapter with it's names, then i would like to sent the created list to a ListActivity so the user can select one.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查此如何在 Android 应用程序中的 Activity 之间传递数据?。最好不要通过 Intent 发送 ArrayAdapter,而只发送数据(ArrayList 甚至 String[]),然后在新的 Activity 中构造 ArrayAdapter。
Check this How do I pass data between Activities in Android application?. It will be better not to send the ArrayAdapter via Intent but to send only the data (ArrayList or even String[]) and then to construct the ArrayAdapter in the new Activity.
您可以查看此,它解释了如何跨活动传递 int[]通过
Intent.putExtra()
。另一种选择是,您可以将希望其他活动访问的数据设置为公共静态,以便其他活动可以自由访问它。You can take a look at this which explains how to pass a int[] across activities through
Intent.putExtra()
. Another option is that you would make the data that you want accessible by the other activity aspublic static
so the other activity could just access it freely.