How to read and write Enum into parcel on Android?

后端 未结 6 723
旧时难觅i
旧时难觅i 2021-02-01 12:18

Here is my model class:

public enum Action {
    RETRY, SETTINGS
}

private int imageId;
private String description;
private String actionName;
private Action ac         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 12:55

    Any enum is serializable.

    You can do this in writeToParcel(): dest.writeSerializable(action)

    And in the constructor: action = (Action) in.readSerializable()

提交回复
热议问题