I am working on an app that uses this example as a base. Scroll down to the class called "DetailsFragment". You will see this method:
public static DetailsFragment newInstance(int index) {
DetailsFragment f = new DetailsFragment();
// Supply index input as an argument.
Bundle args = new Bundle();
args.putInt("index", index);
f.setArguments(args);
return f;
}
Why is this method static ? Couldn't this be done like a regular constructor like this:
public DetailsFragment(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
this.setArguments(args);
}
And then when you need the object just go:
DetailsFragment f = new DetailsFragment(somevalue);
I don't see why this method is static.