Parcelable CREATOR理解

时间:2016-10-20 17:06:41

标签: android parcelable

我无法理解Parcelable的工作方式。特别是很难理解为什么需要CREATOR属性。为什么我们需要实现这样复杂的构造而不是实现readFromParcel(Parcel in)?

1 个答案:

答案 0 :(得分:0)

You need a CREATOR to generate instance of your Parcelable class from a Parcel. What this means is you are creating object of your parceled class with all class member variables initialized from Parcel. You cannot access class variables directly from parcel.