簡體   English   中英

如何在Android中將包含對象列表的對象列表從一個活動傳遞到另一個活動

[英]How to pass List of objects which again contains List of objects from one activity to another in Android

在給定的類下面,我想傳遞給另一個活動的列表。 清單健康;(如何包裹此類的清單)

public class HealthDiagnosis  {

    @SerializedName("Issue")
    private DiagnosedIssue issue;

    @SerializedName("Specialisation")
    private List<DiagnosedSpecialisation> specialisation;

    public DiagnosedIssue getIssue() {
        return issue;
    }

    public void setIssue(DiagnosedIssue issue) {
        this.issue = issue;
    }

    public List<DiagnosedSpecialisation> getSpecialisation() {
        return specialisation;
    }

    public void setSpecialisation(List<DiagnosedSpecialisation> specialisation) {
        this.specialisation = specialisation;
    }
}

要簡單地打包任何復雜的對象,請使用以下網站: http : //www.parcelabler.com/

只是把你的課放在那兒。 然后生成包裹類。 將其復制到您的項目。 對所有三個班級一一進行。

然后使用intent putExtra傳遞父對象:

Intent intent = new Intent(MainActivity.this,AnotherActivity.class);  
intent.putExtra("Key", healthDiagnosis);
startActivity(intent);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM