美文网首页
intent bundle enum

intent bundle enum

作者: doumi | 来源:发表于2017-03-28 13:31 被阅读80次

Enums are Serializable so there is no issue.
Given the following enum:

enum YourEnum { TYPE1, TYPE2}

Bundle:

// put
bundle.putSerializable("key", YourEnum.TYPE1);
// get 
YourEnum yourenum = (YourEnum) bundle.get("key");

Intent:

// put
intent.putExtra("key", yourEnum);
// get
yourEnum = (YourEnum) intent.getSerializableExtra("key");

Not Good

enum.ordinal() = int
values()[int] = enum

相关文章

网友评论

      本文标题:intent bundle enum

      本文链接:https://www.haomeiwen.com/subject/gkejottx.html