Code example for Fragment

Methods: setArguments, setRetainInstance

0
	 
	public static LegislatorProfileFragment create(Legislator legislator) {
		LegislatorProfileFragment frag = new LegislatorProfileFragment();
		Bundle args = new Bundle();
		args.putSerializable("legislator", legislator);
		frag.setArguments(args);
		frag.setRetainInstance(true);
		return frag;
	} 
	 
	public LegislatorProfileFragment() {} 
	 
	@Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        FragmentUtils.setupAPI(this);
         
        legislator = (Legislator) getArguments().getSerializable("legislator");
        loadPhoto(); 
	}