android parcel传递数组的方法是什么


在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进行操作


上一篇:java重定向如何带参数

下一篇:python中describe的作用是什么


android
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器