joshua-r2
10/12/2017 - 3:55 PM

Fragment Instantiator

Standard Fragment Instantiator

//This is a fairly standard way of instantiating a Fragment 
//The Bundle can be retrieved by calling getArguments()

public static YourCustomFragment newInstance(int input1, String input2){
        //Instantiate Fragment ye olde way
        YourCustomFragment fragment = new YourCustomFragment();
        //This Bundle is how we will pass our inputs
        Bundle args = new Bundle();
        //Pack our inputs into the bundle
        args.putLong("TheIntYouNeed", input1);
        args.putString("TheStringYouNeed", input2);
        
        fragment.setArguments(args);
        return fragment;
    }