2015-01-21 3 views
-2

// 소포에서 읽는 동안 오류가 발생하여 배열 목록에서 void를 변환 할 수 없습니다.안드로이드의 소포에서 읽는 중 오류가 발생했습니다.

Source Code: 






public class GetTripsByUserIdModel implements Parcelable{ 

    private static final long serialVersionUID = 1L; 
    private String success; 
    private String tripId; 
    private String tripRequestedBy; 
    private String [] tripRequestedTo; 
    private String tripAcceptedById; 
    private String tripAcceptedByName; 
    private String tripConductedBy; 
    private String tripStatus; 
    private String tripCreatedOn; 
    private String tripScheduledBeginOn; 
    private String tripScheduledEndOn; 
    private String tripStartOn; 
    private String tripCompleteOn; 
    private String tripNotes; 
    private ArrayList<TripDetailModel> tripDetails; 

    private boolean mIsSeparator; 


    public GetTripsByUserIdModel() { 
     // TODO Auto-generated constructor stub 
    } 

    public GetTripsByUserIdModel(String tripId, String tripRequestedBy,String tripAcceptedById,String tripAcceptedByName,String tripConductedBy 
     ,String tripStatus,String tripCreatedOn,String tripScheduledBeginOn,String tripScheduledEndOn, 
     String tripStartOn,String tripCompleteOn,String tripNotes,ArrayList<TripDetailModel> tripDetails,boolean mIsSeparator){ 

     this.tripId = tripId; 
     this.tripRequestedBy = tripRequestedBy; 
     this.tripAcceptedById = tripAcceptedById; 
     this.tripAcceptedByName = tripAcceptedByName; 
     this.tripConductedBy = tripConductedBy; 
     this.tripStatus = tripStatus; 
     this.tripCreatedOn = tripCreatedOn; 
     this.tripScheduledBeginOn = tripScheduledBeginOn; 
     this.tripScheduledEndOn = tripScheduledEndOn; 
     this.tripStartOn = tripStartOn; 
     this.tripCompleteOn = tripCompleteOn; 
     this.tripNotes = tripNotes; 
     this.tripDetails = tripDetails; 
     this.mIsSeparator = mIsSeparator; 

    } 


    public GetTripsByUserIdModel(Parcel in) { 
     readFromParcel(in); 
    } 



    private void readFromParcel(Parcel in) { 

      this.success = in.readString(); 
      this.tripId = in.readString(); 
      this.tripRequestedBy = in.readString(); 
      //this.tripRequestedTo = in.readStringArray(tripRequestedTo); 
      this.tripAcceptedById = in.readString(); 
      this.tripAcceptedByName = in.readString(); 
      this.tripConductedBy = in.readString(); 
      this.tripStatus = in.readString(); 
      this.tripCreatedOn = in.readString(); 
      this.tripScheduledBeginOn = in.readString(); 
      this.tripScheduledEndOn = in.readString(); 
      this.tripStartOn = in.readString(); 
      this.tripCompleteOn = in.readString(); 
      this.tripNotes = in.readString(); 
      this.tripDetails = new ArrayList<TripDetailModel>(); 
      this.tripDetails = in.readTypedList(this.tripDetails, TripDetailModel.CREATOR); 


     } 

    } 

// 마지막 줄에서 "in.readTypedList"를 읽는 중. ArrayList()로 void를 변환 할 수 없다는 오류가 발생했습니다.

//Please suggest any mistake i am doing. 

+0

. 과제를 삭제 해보십시오. this.tripDetails = in.readTypedList (this.tr ... http://stackoverflow.com/questions/6774645/android-how-to-use-readtypedlist-method-correctly-in-a- 이해할 수있는 수준의 – Deshan

답변

1

공공 최종 무효 readTypedList (목록 목록 작성자 c)를 RESOLVE주십시오. readTypedList의 반환 유형이 void입니다.

http://developer.android.com/reference/android/os/Parcel.html#readTypedList(java.util.List, android.os.Parcelable.Creator) 당신은 왜 다시 this.tripDetails에 in.readTypedList의 반환 값을 할당하는 매개 변수로 this.tripDetails을 전달하는 in.readTypedList

private void readFromParcel(Parcel in) { 

      this.success = in.readString(); 
      this.tripId = in.readString(); 
      this.tripRequestedBy = in.readString(); 
      //this.tripRequestedTo = in.readStringArray(tripRequestedTo); 
      this.tripAcceptedById = in.readString(); 
      this.tripAcceptedByName = in.readString(); 
      this.tripConductedBy = in.readString(); 
      this.tripStatus = in.readString(); 
      this.tripCreatedOn = in.readString(); 
      this.tripScheduledBeginOn = in.readString(); 
      this.tripScheduledEndOn = in.readString(); 
      this.tripStartOn = in.readString(); 
      this.tripCompleteOn = in.readString(); 
      this.tripNotes = in.readString(); 
      this.tripDetails = new ArrayList<TripDetailModel>(); 
      /*this.tripDetails = in.readTypedList(this.tripDetails, TripDetailModel.CREATOR);*/ 

      in.readTypedList(this.tripDetails, TripDetailModel.CREATOR); 


     } 
관련 문제