Passing ArrayList Between Activities

后端 未结 2 2079
孤独总比滥情好
孤独总比滥情好 2021-02-06 15:34

i\'ve implemented a Parcelable class:

public class Evento implements Parcelable {
    private int;
    private String ;
    private String imagen;
    //more at         


        
相关标签:
2条回答
  • 2021-02-06 16:29

    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

    0 讨论(0)
  • 2021-02-06 16:30

    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);
    
    0 讨论(0)
提交回复
热议问题