android intent传递对象和集合

android intent传递对象和集合  

2014-11-06 17:38:07|  分类: Android技术 |举报 |字号 订阅

下载LOFTER客户端
传递对象
 
   

Article article = JsonUtils.getArticle(content); intent = new Intent(activity, CompositionCorrect.class); Bundle bundle = new Bundle(); bundle.putSerializable("ARTICLE", article); intent.putExtras(bundle); startActivity(intent);



获取传递的对象
 
   

private void initIntentData() { intent = getIntent(); article = (Article) intent.getSerializableExtra("ARTICLE"); tv_content.setText("" + article.getContent()); spannableStringBuilder = new SpannableStringBuilder(tv_content.getText().toString()); }

传递集合
 
   

intent = new Intent(CompositionCorrectActivity.this, PiGaiCompletedActivity.class); Bundle bundle = new Bundle(); for (int i = 0; i < mSpansCommit.size(); i++) { mSpansCommit.get(i).setColorSpan(null); } bundle.putSerializable("MSPANSCOMMIT", (Serializable) mSpansCommit); bundle.putSerializable("ARTICLE", article); intent.putExtras(bundle); startActivity(intent);

获取集合
 
  

mSpansCommit = (List<Span>) intent.getSerializableExtra("MSPANSCOMMIT");

你可能感兴趣的:(android)