zoukankan      html  css  js  c++  java
  • 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.         //铵钮点击事件响应  
    请注明出处,此文档来自“善思善学”。
  • 相关阅读:
    UVa-272-TEX Quotes
    UVa-10881-蚂蚁
    UVa-1339-古老的密码
    POJ-1328-放置雷达
    POJ-3190-分配畜栏
    Openjudge-2787-算24
    WHYZOJ-#47. 滑行的窗口(单调队列)
    2017年9月16日18:03:54
    WHYZOJ-#93. 暗黑破坏神(垃圾01背包)
    WHYZOJ-#95 大逃亡(二分+BFS)(好题!!!)
  • 原文地址:https://www.cnblogs.com/gtgl/p/3927169.html
Copyright © 2011-2022 走看看