不可转换的类型 不能将<Parcelable>数组列表强制转换为



有错误的行:

PersonList persons;
persons = (PersonList) intent.getParcelableArrayListExtra(EXTRA_PERSON_LIST);

PersonList的声明方式:

public class PersonList extends ArrayList<Person> {

人员申报方式:

public class Person extends CommonObject implements Parcelable {

由于PersonList扩展了ArrayList(Person),Person实现了Parcelable,所以不确定为什么这不起作用。

你不能用这种方式。

ArrayList<Person>  l = ...;
PersonList p = (PersonList) l; // Not possible
PersonList p = ...;
ArrayList<Person> l = p; // This will work
  • PersonListPersonArrayList
  • PersonArrayList并不总是PersonList

最新更新