相关疑难解决方法(0)

将自定义对象的数组列表传递给另一个活动

单击单元格时,对象将添加到数组中。这个数组需要传递到另一个活动中。出于测试目的,我传递了只有一个对象 DoctorObject 的数组。然后在下一个活动中,我使用 .getName() 以字符串形式获取名称并将其显示在吐司中。然而吐司是空的。

这是代码的一些片段

目的:

public class DoctorObject implements Parcelable {

private List<Object> mChildrenList;

public DoctorObject(String name) {
    Docname = name;

}

public DoctorObject (Parcel in){
    this.DocPic = in.readInt();
    this.Docname= in.readString();
    this.Docspecialty = in.readString();
    this.DocLocation = in.readString();
}

String Docname = "";

public String getDocname() {
    return Docname;
}

public void setDocname(String docname) {
    Docname = docname;
}

public int getDocPic() {
    return DocPic;
}

public void setDocPic(int docPic) {
    DocPic = docPic;
}

public String getDocspecialty() { …
Run Code Online (Sandbox Code Playgroud)

arrays android parcelable android-activity

2
推荐指数
1
解决办法
2000
查看次数

标签 统计

android ×1

android-activity ×1

arrays ×1

parcelable ×1