我的活动 WorkerActivity 包含一些工作人员的列表,我试图将单击的工作人员对象传递给我的 WorkerDetailActivity。我对java和android相对较新,所以我正在寻找可能的解决方案,因为这里的大多数答案都建议不要序列化并建议使用parcelable,我尝试这样做,就像这里建议的那样:How to
pass a Parcelable object that contains对象列表?
最后 3 行代码,该部分in.readList(machinePossession, null);
显示以下错误:
类型不匹配:无法从 void 转换为 List<Machine>
我不知道如何处理这个问题,很乐意接受任何建议。
我删除了包以及所有构造函数、setter 和 getter,以保持发布的代码干净。
import java.util.ArrayList;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
public class Worker implements Parcelable{
private String workerID;
private String workerPersonnelNR;
private String workerLastName;
private String workerName;
private String workerCategory;
private String historyName;
private String historyID;
private String historyFrom;
private String historyTo;
private String historyActive;
private String historyDays;
public List<Machine> machinePossession = new ArrayList<Machine>();
public …Run Code Online (Sandbox Code Playgroud)