傳遞obj給fragment的三種方式

參考:http://stackoverflow.com/questions/10836525/passing-objects-in-to-fragments


There are 3 ways to pass objects to a fragment

They are:

  1. Passing the object through a setter is the fastest way, but state will not be restored automatically.
  2. setArguments with Serializable objects is the slowest way (but okay for small objects, I think) and you have automatic state restoration.
  3. Passing as Parcelable is a fast way (prefer it over 2nd one if you have collection of elements to pass), and you have automatic state restoration.

http://developer.android.com/reference/android/os/Parcelable.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章