在Android中,可以使用Bundle类来传递数组。首先,将数组放入Bundle中,然后将Bundle传递给Intent对象,最后在接收方从Intent对象中获取Bundle并取出数组。
示例代码如下:
发送方:
String[] array = {"item1", "item2", "item3"};
Bundle bundle = new Bundle();
bundle.putStringArray("myArray", array);
Intent intent = new Intent(this, ReceiverActivity.class);
intent.putExtras(bundle);
startActivity(intent);
接收方:
Bundle bundle = getIntent().getExtras();
String[] array = bundle.getStringArray("myArray");
// 现在你可以使用获取的数组array进行操作
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至 55@qq.com 举报,一经查实,本站将立刻删除。转转请注明出处:https://www.szhjjp.com/n/942320.html