Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // Get
  2. public YourFragment newInstance(your arguments here)
  3. {
  4. Fragment fragment = new YourFragment();
  5. Bundle bundle = new Bundle();
  6.  
  7. // something like this for each arg
  8. bundle.putArg(argKey, arg);
  9.  
  10. fragment.setArguments(bundle);
  11.  
  12. return fragment;
  13. }
  14.  
  15.  
  16. // then in onCreate get the bundle and grab the args
  17. @Override
  18. public void onCreate()
  19. {
  20. Bundle bundle = getArguments();
  21.  
  22. arg1 = bundle.getArg(arg1Key);
  23. // and so on
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement