Passing ArrayList<CustomObject> Between Activities

我的未来我决定 提交于 2019-12-03 08:37:03
Tofeeq Ahmad

This code

Bundle informacion= new Bundle();
informacion.putParcelableArrayList("eventos", ArrayList<Eventos> eventos);
intent.putExtras(informacion);

Should be

Bundle informacion = new Bundle();
ArrayList<Eventos> mas = new ArrayList<Eventos>();
informacion.putSerializable("eventos", mas);
intent.putExtras(informacion);

and Make sure your Eventos structure like a serializable object

private class Eventos implements Serializable {

}

Reading Values

ArrayList<Eventos> madd=getIntent().getSerializableExtra(key);

Parcelable is much better than serialization in a performance wise and other features.

refer this link:

http://www.3pillarglobal.com/insights/parcelable-vs-java-serialization-in-android-app-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!