java - Parcelable vs Serializable - for classes without any fields -
often have pass fragment (or activity) interface instance without internal data. pass fragment (or activity), should write bundle
(or intent
) parcelable
or serializable
. take these 2 options ?
example:
public class somefragment { public static interface helper { view prepareview(somefragment fragment, layoutinflater inflater); // etc. } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { homecoming extracthelperfromarguments().prepareview(this, inflater); } public static somefragment newinstance(helper helper) { somefragment fragment = new somefragment(); // // bundle args = new bundle(); // // args.putparcelable(key_helper, (parcelable) helper); // or // args.putserializable(key_helper, (serializable) helper); // ? // // fragment.setarguments(args) homecoming fragment; } }
if take parcelable
have declare static field creator
, empty methods describecontents()
, writetoparcel()
(empty because class doesn't have fields).
if take serializable
don't have anything.
sorry english
hi here link after reading have no more questions regarding parcelable vs serializable..
link
java android serialization parcelable
No comments:
Post a Comment