将自定义对象传递给Bottomsheetdialog

时间:2021-01-23 19:20:43

标签: java android

我像这样实现了我的用户模型; public class UserModel implements Parcelable {

我正在尝试将我的自定义对象发送到我的BottomSheetDialog,这是我的代码;

 ArrayList<UserModel> userModelArrayList = new ArrayList<UserModel>();
 BottomSheetDialog_modifed bottomSheetDialog_modifed = new BottomSheetDialog_modifed();
    Bundle bundle = new Bundle();
    bundle.putParcelable("customObject", userModelArrayList);//i got problem here
    bottomSheetDialog_modifed.setArguments(bundle);

但是我遇到了这样的错误;

error: incompatible types: ArrayList<UserModel> cannot be converted to Parcelable
    bundle.putParcelable("customObject", userModelArrayList);

1 个答案:

答案 0 :(得分:0)