首页 > 代码库 > Activity传递对象的方法
Activity传递对象的方法
- //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);
- }
- //铵钮点击事件响应
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。