2013-04-21 78 views
0

我不知道是否有另一個我的Parcelable類有什麼問題嗎?

這裏有毛病我班,因爲我無法通過額外的(由注對象組成)從活動是我Parcelable類的代碼:注意:

public class Note implements Parcelable { 

    public static int compteur = 0; 
    long id; 
    String summary; 
    String details; 

    public Note(String summary, String details) { 
     super(); 
     compteur = compteur + 1; 
     this.id = compteur; 
     this.summary = summary; 
     this.details = details; 
    } 

    public Note() { 
     super(); 
    } 

    ///// getters and settters ///// 

    @Override 
    public String toString() { 
     return "Note " + id + " (" + summary + ") --> Details: " + details; 
    } 

    @Override 
    public int describeContents() { 
     // TODO Auto-generated method stub 
     return 0; 
    } 

    @Override 
    public void writeToParcel(Parcel dest, int arg1) { 
     // TODO Auto-generated method stub 
     dest.writeLong(id); 
     dest.writeString(summary); 
     dest.writeString(details); 

    } 

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

     @Override 
     public Note createFromParcel(Parcel in) { 
      // TODO Auto-generated method stub 
      return new Note(in); 
     } 

     public Note[] newArray(int size) { 
      return new Note[size]; 
     } 
    }; 

    private Note(Parcel in) { 
     this.id = in.readInt(); 
     this.summary = in.readString(); 
     this.details = in.readString(); 
    } 
} 

或者,也許問題是其他地方?

回答

0

嘗試使您的Note構造函數接受Parcel public。

public Note(Parcel in) { 
     this.id = in.readInt(); 
     this.summary = in.readString(); 
     this.details = in.readString(); 
    } 
+0

我把它改成公共但不幸的是根據你的問題它不工作:( – Siho 2013-04-21 19:55:09

+0

任何其他的想法? – Siho 2013-04-21 19:57:05

+0

,做我收集正確的,你正試圖從一個活動傳遞注包裹另一個? – keannan5390 2013-04-21 20:01:18