July 2015
Beginner to intermediate
600 pages
18h 59m
English
Every fragment instance can have a Bundle object attached to it. This bundle contains key-value pairs that work just like the intent extras of an Activity. Each pair is known as an argument.
To create fragment arguments, you first create a Bundle object. Next, you use type-specific “put” methods of Bundle (similar to those of Intent) to add arguments to the bundle:
Bundle args = new Bundle();
args.putSerializable(EXTRA_MY_OBJECT, myObject);
args.putInt(EXTRA_MY_INT, myInt);
args.putCharSequence(EXTRA_MY_STRING, myString);
To attach the arguments bundle to a fragment, you call Fragment.setArguments(Bundle). Attaching arguments to a fragment must be done after ...
Read now
Unlock full access