Intent传Model

1.在model里面实现Serializable
重点,model中嵌套了其它的实体类 也需要实现


implements Serializable

image.png

2.传值


 Intent intent = new Intent(mContext, PostDetailActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("modelList", modelList.get(position));
                intent.putExtras(bundle);
                intent.putExtra("topicType", "1");
                mContext.startActivity(intent);

3.获取


model= (TopicDetailsListModel) getIntent().getSerializableExtra("modelList");

你可能感兴趣的:(Intent传Model)