简体   繁体   English

如何意图ArrayList <ClassObject> 从片段到活动

[英]How to intent ArrayList<ClassObject> from Fragment To Activity

I want to send ArrayList contains getter setter class objects. 我要发送包含getter setter类对象的ArrayList。 But I'm facing an error like: 但我遇到了类似的错误:

The method putParcelableArrayListExtra(String, ArrayList<? extends Parcelable>) in the type Intent is not applicable for the arguments (String, ArrayList<BloodDonor>)

// Call New Activity //调用新活动

ArrayList<BloodDonor> bloodDonors = filterData(selectedCountry, selectedState, selectedCity, selectedZip, selectedbloodgroup);
Intent intent = new Intent(getActivity(), DonerListActivity.class);
intent.putParcelableArrayListExtra("bloodDonorList", bloodDonors);
startActivity(intent);

// declaration of filterData() method. //声明filterData()方法。

private ArrayList<BloodDonor> filterData(String SelectedCountry,
        String selectedState, String selectedCity, String selectedZip,
        String bloodgroup) {

    ArrayList<BloodDonor> bloodDonor = new ArrayList<BloodDonor>();

    Log.d("DB", "values in filter" + SelectedCountry + selectedState
            + selectedCity + selectedZip);

    DatabaseHelperDao helperDao = new DatabaseHelperDao(getActivity());
    try {
        helperDao.open();
        bloodDonor = helperDao.fatchDoner(SelectedCountry,
                selectedState, selectedCity, selectedZip, bloodgroup);
    } catch (Exception e) {
        e.getStackTrace();
    } finally {
        helperDao.close();
    }
    return bloodDonor;

}

dao method fetchdonor() return donors list. dao方法fetchdonor()返回捐助者列表。 Please Help me here.Thanks 请在这里帮助我。谢谢

Probably you missed to implements Parcelable interface in your BloodDonor object. 也许你错过了实现Parcelable在你的界面BloodDonor对象。

More information about Parcelable you can find here . 您可以在此处找到有关Parcelable更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM