关于intent.putParcelableArrayListExtra();中list的写法

 
  
最初的写法如下,
intent.putParcelableArrayListExtra("LIST", list);中的list报错,Wrong 2nd argument type. Found:'java.util.List',required: 'java.util.ArrayList'
public void getSchoolMajorSuccess(List list) {
        Intent intent = new Intent(mContext, DepartmentMajorSelectActivity.class);
        intent.putExtra("TYPE",1);
        intent.putParcelableArrayListExtra("LIST", list);
        startActivityForResult(intent, REQUESTCODE_MAJOR);
    }
后改成如下方式,完美解决~

 
  
public void getSchoolDepartmentSuccess(List list) {
        Intent intent = new Intent(mContext, DepartmentMajorSelectActivity.class);
        intent.putExtra("TYPE",0);
        ArrayList mList = new ArrayList<>();
        mList.addAll(list);
        intent.putParcelableArrayListExtra("LIST", mList);
        startActivityForResult(intent, REQUESTCODE_DEPARTMENT);
    }

你可能感兴趣的:(关于intent.putParcelableArrayListExtra();中list的写法)