jackyshan

导航

 
  • 传值代码块

    //Serializeable传递对象的方法
    public void SerializeMethod(){
    Person mPerson = new Person();
    mPerson.setName("frankie");
    mPerson.setAge(25);
    Intent mIntent = new Intent(this,ObjectTranDemo1.class);
    Bundle mBundle = new Bundle();
    mBundle.putSerializable(SER_KEY,mPerson);
    mIntent.putExtras(mBundle);

    startActivity(mIntent);
    }
    //Pacelable传递对象方法
    public void PacelableMethod(){
    Book mBook = new Book();
    mBook.setBookName("Android Tutor");
    mBook.setAuthor("Frankie");
    mBook.setPublishTime(2010);
    Intent mIntent = new Intent(this,ObjectTranDemo2.class);
    Bundle mBundle = new Bundle();
    mBundle.putParcelable(PAR_KEY, mBook);
    mIntent.putExtras(mBundle);

    startActivity(mIntent);
    }

posted on 2016-01-22 18:16  jackyshan  阅读(296)  评论(0)    收藏  举报