-1

I am working on swipe views and tab vies in Android Studio and while looking for help online i found the following code:

public static player newInstance(int sectionNumber) {

    player fragment = new player();
    Bundle args = new Bundle();
    args.putInt(ARG_SECTION_NUMBER, sectionNumber);
    fragment.setArguments(args);

    return fragment;
  }

However when i deleted this code the application worked as expected.

Can you please tell me what this code is exactly doing as I am only a beginner yet

Thanks alot

S Zain Bukhari
  • 135
  • 1
  • 1
  • 11
  • It creates a new instance of fragment `player` assign some kind of an int argument and returns that instance for further use (or not in your case). – Simas Jul 14 '14 at 00:07

1 Answers1

0

The int is an extra parsed to the player fragment. In the code you simply instantiating a new fragment player. Nothing much

  • Can you elaborate? Your answer is a bit hard to understand. – drum Jul 14 '14 at 02:34
  • Well it's easy. Wen you need to give data into a next activity which you are starting you use extras to give it the data. For the code you provided the next fragment needs the int and thts why there is put extra and set arguments to include it in the fragment which is then started. This is too plain I hope you now get – PewDiePie001 Jul 15 '14 at 10:34