{"id":718,"date":"2023-02-26T15:25:17","date_gmt":"2023-02-26T07:25:17","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=718"},"modified":"2023-04-29T17:15:19","modified_gmt":"2023-04-29T09:15:19","slug":"android-parcelable-write-enumeration","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/android-parcelable-write-enumeration\/","title":{"rendered":"Android Parcelable\u4e2d\u679a\u4e3e\u7684\u5199\u6cd5"},"content":{"rendered":"<pre><code class=\"language-java\">public enum CouponType implements Parcelable {\n    UNKNOWN,\n    FIXED,\n    PERCENT;\n\n    @Override\n    public int describeContents() {\n        return 0;\n    }\n\n    @Override\n    public void writeToParcel(Parcel dest, int flags) {\n        dest.writeInt(ordinal());\n    }\n\n    public static final Creator&lt;CouponType&gt; CREATOR = new Creator&lt;CouponType&gt;() {\n        @Override\n        public CouponType createFromParcel(Parcel in) {\n            return  CouponType.values()[in.readInt()];\n        }\n\n        @Override\n        public CouponType[] newArray(int size) {\n            return new CouponType[size];\n        }\n    };\n}<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u5728\u5b9e\u4f53\u7c7b\u4e2d\u5199\u5165\u4e0e\u8bfb\u53d6\u65f6<\/p>\n<pre><code class=\"language-java\">\/\/\u5199\u5165\uff0cwriteToParcel\u65b9\u6cd5\u4e2d\ndest.writeParcelable(couponType, flags);\n\n\/\/\u8bfb\u53d6\uff0c\u6784\u9020\u65b9\u6cd5\u4e2d\ncouponType = in.readParcelable(CouponType.class.getClassLoader());<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>public enum CouponType implements Parcelable { UNKNOWN, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-718","post","type-post","status-publish","format-standard","hentry","category-android-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=718"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/718\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}