Please note that Drawable class in not Serializeable.
On 9 May 2012 14:26, Brian Collo Gonçalves <dev.br...@ngm.com.br> wrote: > I have 2 serializable classes as follow: > > @SuppressWarnings("serial") > public class Musicas implements Serializable { > private String musica; > private String link; > public Musicas(String musica, String link) { > super(); > this.musica = musica; > this.link = link; > } > public String getMusica() { > return musica; > } > public void setMusica(String musica) { > this.musica = musica; > } > public String getLink() { > return link; > } > public void setLink(String link) { > this.link = link; > } > } > > > > > @SuppressWarnings("serial") > public class CDs implements Serializable { > private Drawable Picture; > private String Descricao; > private int idCD; > private ArrayList<Musicas> musicas; > public ArrayList<Musicas> getMusicas() { > return musicas; > } > public void setMusicas(ArrayList<Musicas> musicas) { > this.musicas = musicas; > } > public int getIdCD() { > return idCD; > } > public void setIdCD(int idCD) { > this.idCD = idCD; > } > public Drawable getPicture() { > return Picture; > } > public void setPicture(Drawable picture) { > Picture = picture; > } > public String getDescricao() { > return Descricao; > } > public void setDescricao(String descricao) { > Descricao = descricao; > } > public CDs(Drawable drawable, String descricao, int idcd) { > super(); > Picture = drawable; > Descricao = descricao; > idCD = idcd; > } > public CDs(Drawable picture, String descricao, int idCD, > ArrayList<Musicas> musicas) { > this(picture, descricao, idCD); > setMusicas(musicas); > } > } > > > > Where my CD Class have an ArrayList of Musics. > In my activity, I load the data from a Json to make a gallery of CDs > and selecting the CD i have the following code to pass the CD->Musics > to a new activity. > > ArrayList<CDs> cds = new ArrayList<CDs>(); > ArrayList<Musicas> musicas = new ArrayList<Musicas>(); > JSONObject json = new JSONObject(sb.toString()); > for (int i=1; i <= > json.getJSONObject("cds").length()-1; i++) { > JSONArray jarrayfilho = > json.getJSONObject("cds").getJSONArray(String.valueOf(i)); > ArrayList<Musicas> musicas1 = new > ArrayList<Musicas>(); > for(int j = 0; j < > jarrayfilho.length(); j++) > { > musicas1.add(new Musicas( > > jarrayfilho.getJSONObject(j).getString("NOME").toString(), > > jarrayfilho.getJSONObject(j).getString("LINK").toString())); > } > musicas = musicas1; > cds.add(new CDs( > ImageOperations(this, > jarrayfilho.getJSONObject(0).getString("IMG").toString()), > > jarrayfilho.getJSONObject(0).getString("CD").toString(), i, > musicas > ) > ); > gallery.setOnItemClickListener(new OnItemClickListener() { > @Override > public void onItemClick(AdapterView<?> arg0, View > arg1, int arg2, > long arg3) { > Intent musicas = new Intent(arg1.getContext(), > MusicasActivity.class); > musicas.putExtra("cd", cds.get(arg2)); > startActivity(musicas); > } > }); > > > But when I call the click event, I get the error: Parcelable > encountered IOException writing serializable object > > Can anyone guide me through this? I have tried everything I found on > internet but no clues. What I found that may solve is create a static > class/properties, but I don't want to reach this aproach since it's > not recomended for memory issues and all. > > Best Regards. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Daniel Drozdzewski -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en