esoni
esoni

Reputation: 1362

What is the difference between creating fragment with a factory method and Fragment.instantiate?

Hi mate I am using pageview "JakeWharton-lib", I saw an example on web, and in some example used factory method to create fragment.

  @Override
    public Fragment getItem(int position) {
        return TestFragment.newInstance(CONTENT[position % CONTENT.length]);
    }

and in other example use Fragment.Instantiate(...) what is the difference ?

Upvotes: 0

Views: 204

Answers (1)

Alexander
Alexander

Reputation: 48262

newInstance is not a part of Fragments API, it's a convenience helper method. It can have whatever signature is convenient in a particular case. Whereas instantiate is a part of API. It has a fixed signature.

Upvotes: 1

Related Questions