Java 尝试写入包裹时出错
在我的Parcelable类中,在Java 尝试写入包裹时出错,java,android,parcelable,parcel,Java,Android,Parcelable,Parcel,在我的Parcelable类中,在writeToParcel方法中,我得到以下错误: Inferred type 'MyObject' for type parameter 'T' is not within its bound; should implement 'android.os.Parcelable 当我尝试编写ArrayList时,通过以下方式: dest.writeTypedList(new ArrayList<MyObject>()); dest.writeTy
writeToParcel
方法中,我得到以下错误:
Inferred type 'MyObject' for type parameter 'T' is not within its bound; should
implement 'android.os.Parcelable
当我尝试编写ArrayList时,通过以下方式:
dest.writeTypedList(new ArrayList<MyObject>());
dest.writeTypedList(新的ArrayList());
在我的代码中,我可以通过dest.writeString
编写字符串,但是当我尝试编写MyObject
的Array
时,我得到了上述错误
我怎样才能解决这个问题
将ArrayList写入地块对象的最佳方式是什么
谢谢大家! 正如@devconsole所指出的,您的类MyObject是实现“android.os.Parcelable”所必需的,与错误消息所说的差不多 您可以在此处找到一个示例:
转到您的“MyObject”类,确保它实现了Parcelable,您将看到错误消失了MyObject是否实现了Parcelable?hi@bgse在我的问题中,消息是:类型参数“T”的推断类型“MyObject”不在其范围内;应实现“android.os.Parcelable”