1

Im trying to pass an arrayList from activity A to another activity B. The object class I am using implements Parcelable. In A activity the arrayList seems to be well formed, but when I try to get it back in B activity it is incomplete.

I mean: The arrayList in activity A has 5 objects: [modelo.Restaurante@419a1810, modelo.Restaurante@419a1d38, modelo.Restaurante@419a1ec0, modelo.Restaurante@419a2010, modelo.Restaurante@419a21b8]

The arrayList I get in activity B has only 3 object, and two null or empty values: [modelo.Restaurante@419b1398, , modelo.Restaurante@419b1658, null, modelo.Restaurante@419b18c8]

If I try with different number of elements it always makes the fault in odd positions.

Could anyone help me?

Here the code:

Activity A where a put the arrayList in the intent:

  Intent intent = new Intent(BuscadorPrincipalActivity.this, ListaRestaurantes.class);
        intent.putParcelableArrayListExtra("jatetxeak", restaurantes);  

            startActivity(intent);

Activity B where I get want to get it again:

Bundle extras = getIntent().getExtras();
          if(extras !=null)
          {
             array_restaurantes=   extras.getParcelableArrayList("jatetxeak");

          } 

Object class that implements parcelable:

public class Restaurante implements Parcelable{

private int idRestaurante;
private int idPueblo;
private String nombre;
private String direccion;
private String telefono;
private String mail;
private String web;
private String tipoDeCocina;
private String horario;
private double latitud;
private double longitud;
private String foto;
private String especialidades;

public Restaurante(int idRestaurante,int idPueblo, String nombre, String direccion,
        String telefono, String mail, String web, String tipoDeCocina,
        String horario, double latitud, double longitud, String foto,
        String especialidades) {
    super();
    this.idRestaurante = idRestaurante;
    this.idPueblo=idPueblo;
    this.nombre = nombre;
    this.direccion = direccion;
    this.telefono = telefono;
    this.mail = mail;
    this.web = web;
    this.tipoDeCocina = tipoDeCocina;
    this.horario = horario;
    this.latitud = latitud;
    this.longitud = longitud;
    this.foto = foto;
    this.especialidades = especialidades;
}

public Restaurante() {
    super();
    // TODO Auto-generated constructor stub
}

public int getIdRestaurante() {
    return idRestaurante;
}

public void setIdRestaurante(int idRestaurante) {
    this.idRestaurante = idRestaurante;
}

public String getNombre() {
    return nombre;
}

public void setNombre(String nombre) {
    this.nombre = nombre;
}

public String getDireccion() {
    return direccion;
}

public void setDireccion(String direccion) {
    this.direccion = direccion;
}

public String getTelefono() {
    return telefono;
}

public void setTelefono(String telefono) {
    this.telefono = telefono;
}

public String getMail() {
    return mail;
}

public void setMail(String mail) {
    this.mail = mail;
}

public String getWeb() {
    return web;
}

public void setWeb(String web) {
    this.web = web;
}

public String getTipoDeCocina() {
    return tipoDeCocina;
}

public void setTipoDeCocina(String tipoDeCocina) {
    this.tipoDeCocina = tipoDeCocina;
}

public String getHorario() {
    return horario;
}

public void setHorario(String horario) {
    this.horario = horario;
}

public double getLatitud() {
    return latitud;
}

public void setLatitud(double latitud) {
    this.latitud = latitud;
}

public double getLongitud() {
    return longitud;
}

public void setLongitud(double longitud) {
    this.longitud = longitud;
}

public String getFoto() {
    return foto;
}

public void setFoto(String foto) {
    this.foto = foto;
}

public String getEspecialidades() {
    return especialidades;
}

public void setEspecialidades(String especialidades) {
    this.especialidades = especialidades;
}

public int getIdPueblo() {
    return idPueblo;
}

public void setIdPueblo(int idPueblo) {
    this.idPueblo = idPueblo;
}

public ContentValues createContentValuesRestaurante(Restaurante restaurante) {
    ContentValues values = new ContentValues();
    values.put("idRestaurante", restaurante.idRestaurante);
    values.put("nombre", restaurante.nombre);
    values.put("direccion", restaurante.direccion);
    values.put("telefono", restaurante.telefono);
    values.put("mail", restaurante.mail);
    values.put("web", restaurante.web);
    values.put("tipoCocina", restaurante.tipoDeCocina);
    values.put("horario", restaurante.horario);
    values.put("latitud", restaurante.latitud);
    values.put("longitud", restaurante.longitud);
    values.put("foto", restaurante.foto);
    values.put("especialidades", restaurante.especialidades);
    return values;
}

public static final Parcelable.Creator<Restaurante> CREATOR = new Parcelable.Creator<Restaurante>(){

    public Restaurante createFromParcel(Parcel source) {
        Log.d ("parcelabler pruebak", "createFromParcel()");
        return new Restaurante(source);
    }

    public Restaurante[] newArray(int size) {
        Log.d ("parcelabler pruebak", "createFromParcel() newArray ");
        return new Restaurante[size];
    }

};


/**
 * This constructor "deserializes" the object.
 * @param in
 */
 private Restaurante (Parcel source) {

   Log.d ("parcelabler pruebak", "parcel source");
    idRestaurante=source.readInt();
    idPueblo=source.readInt();
    nombre=source.readString();
    direccion=source.readString();
    telefono=source.readString();
    mail=source.readString();
    web=source.readString();
    tipoDeCocina=source.readString();
    horario=source.readString();
    latitud=source.readInt();
    latitud=source.readInt();   
    foto=source.readString();
    especialidades=source.readString();


    /// To "deserialize" the HashMap
      /*int hashSize = source.readInt();
      contentSrc = new HashMap<String, String>();
      for (int i = 0; i < hashSize; i++)
          contentSrc.put(source.readString(), source.readString());*/
}


public int describeContents() {

    return 0;
}

public void writeToParcel(Parcel dest, int flags) {

      Log.d ("parcelabler pruebak", "writeToParcel");

  dest.writeInt(idRestaurante);
  dest.writeInt(idPueblo);
  dest.writeString(nombre);
  dest.writeString(direccion);
  dest.writeString(telefono);
  dest.writeString(mail);
  dest.writeString(web);
  dest.writeString(tipoDeCocina);
  dest.writeString(horario);
  dest.writeDouble(latitud);
  dest.writeDouble(longitud);   
  dest.writeString(foto);
  dest.writeString(especialidades);


/// To "serialize" the HashMap
 /* dest.writeInt(contentSrc.size());
  Iterator<Entry<String, String>> i = contentSrc.entrySet().iterator();
  while (i.hasNext()){
      Map.Entry<String, String> e = (Map.Entry<String, String>) i.next();
      dest.writeString(e.getKey());
      dest.writeString(e.getValue());}*/

}

}

I would be really grateful for any help... thank you so much...


It could be very challenging to hit a predifined Excle format with the native BIRT Excel emitter, there are several after market Excel emitters that might help you get there.

The easier way is to set up your BIRT report to export with the format you want, then save report and use it as foundation for recreating the next report. You can use grids, and master pages to get just the layout you want, then plug in report pieces.

You can also use the library to save grids, tables & data sets that you use over and over.

4

0 回答 0