Passing ArrayList Between Activities

后端 未结 2 2122
孤独总比滥情好
孤独总比滥情好 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:30

    This code

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

    Should be

    Bundle informacion = new Bundle();
    ArrayList mas = new ArrayList();
    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 madd=getIntent().getSerializableExtra(key);
    

提交回复
热议问题