Last active
August 29, 2015 14:26
-
-
Save basilbeltran/77ce8327b5f99a47ea57 to your computer and use it in GitHub Desktop.
Fragment with arg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MFragment extends Fragment { | |
private DataObject mDataObject; | |
public static final String EXTRA_M_ID = "com.your.apps.extra_id"; | |
public static MFragment newInstance(UUID id) { // set the args | |
Bundle args = new Bundle(); | |
args.putSerializable(EXTRA_M_ID, id); | |
MFragment fragment = new MFragment(); | |
fragment.setArguments(args); | |
return fragment;} | |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); | |
UUID id = (UUID)getArguments().getSerializable(EXTRA_M_ID); // use the args | |
mDataObject = DataStoreSingleton.get(getActivity()).getObject(id);} | |
}//class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment