從我的應用程序的活動我有一個意圖啓動一個新的活動,我想傳遞一個ArrayList,即一個ArrayList,其中每個項目是一個自己的類的實例。 ..我怎麼能做到這一點?獲取ArrayList <MyClass> getIntent()。getExtras()
我一直看到可能getExtras()像getStringArrayList()或getParcelableArrayList(),它不起作用,我還沒有找到任何有效的類型。
任何人都可以幫助我嗎?謝謝。
這是我的課:
public class ItemFile {
protected long id;
protected String nombre;
protected String rutaImagen;
protected boolean checked;
public ItemFile(long id, String nombre, String rutaImagen, boolean check) {
this.id = id;
this.nombre = nombre;
this.rutaImagen = rutaImagen;
this.checked = check;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getRutaImagen() {
return rutaImagen;
}
public void setRutaImagen(String rutaImagen) {
this.rutaImagen = rutaImagen;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked){
this.checked = checked;
}
}
如何必須改變它來設置Parcelable?
你可以嘗試通過實現與parcabl MyClass即 看看這裏。 http://stackoverflow.com/a/7181792/1602333 – 2014-11-06 12:36:10
這是最好的答案。在這篇文章中,解釋了我的問題。這篇文章的最後回答非常有用。 – KryNaC 2014-11-06 19:28:45