David Velasquez
David Velasquez

Reputation: 2366

Check current fragment in viewpager that was attached in Activity's onAttachFragment()

I have a callback method I need to call once a fragment in my ViewPager is attached to my activity. In order to do this I'm overriding onAttachFragment(Fragment fragment) in the activity.

But I have 3 fragments in the ViewPager, so how can I check the fragment parameter in OnAttachFragment() to make sure it's the specific fragment I need?

If I am going about this wrong, I would like to know how to accomplish this the right way.

Upvotes: 1

Views: 247

Answers (1)

David Velasquez
David Velasquez

Reputation: 2366

Figured it out! Instead of calling OnAttachFragment() in the activity, I'm calling the callback method in onActivityCreated() in the fragment where it needs to be called.

Upvotes: 1

Related Questions