0
public class PageFragment extends Fragment {
public static final String ARG_PAGE = "ARG_PAGE";

private int mPage;

public static PageFragment newInstance(int page) {
    Bundle args = new Bundle();
    args.putInt(ARG_PAGE, page);
    PageFragment fragment = new PageFragment();
    fragment.setArguments(args);
    return fragment;
}

I am confuse about the code above where the fragment has something called setArguments(args).

I am not exactly sure what exactly does this `setArguments(args) and I also want to know what does the getArgument() method do since I saw it while looking at the developer.android.com.

Wowzer
  • 1,103
  • 2
  • 12
  • 26

1 Answers1

0

Used to pass data to fragment, and in the Fragment code, you can call getArguments() to get what you passed to it.

Chen Yuan
  • 1
  • 1
  • So if I am understanding correctly then setArgument allows me to pass a bundle object to that fragment object to store for data right? but what I have above is that the mPager integer has no value right? – Wowzer Dec 04 '15 at 03:22