Activity传递对象的方法

  1. //Serializeable传递对象的方法    
  2.         public void SerializeMethod(){    
  3.             Person mPerson = new Person();    
  4.             mPerson.setName("frankie");    
  5.             mPerson.setAge(25);    
  6.             Intent mIntent = new Intent(this,ObjectTranDemo1.class);    
  7.             Bundle mBundle = new Bundle();    
  8.             mBundle.putSerializable(SER_KEY,mPerson);    
  9.             mIntent.putExtras(mBundle);    
  10.                 
  11.             startActivity(mIntent);    
  12.         }    
  13.         //Pacelable传递对象方法    
  14.         public void PacelableMethod(){    
  15.             Book mBook = new Book();    
  16.             mBook.setBookName("Android Tutor");    
  17.             mBook.setAuthor("Frankie");    
  18.             mBook.setPublishTime(2010);    
  19.             Intent mIntent = new Intent(this,ObjectTranDemo2.class);    
  20.             Bundle mBundle = new Bundle();    
  21.             mBundle.putParcelable(PAR_KEY, mBook);    
  22.             mIntent.putExtras(mBundle);    
  23.                 
  24.             startActivity(mIntent);    
  25.         }    
  26.         //铵钮点击事件响应  
请注明出处,此文档来自“善思善学”。
原文地址:https://www.cnblogs.com/gtgl/p/3927169.html