Last active
September 6, 2017 09:51
-
-
Save code-twister/731d60aca8af6fe212fe151500c8f58e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Object instantiateItem(View container, int position) { | |
if (mCurTransaction == null) { | |
mCurTransaction = mFragmentManager.beginTransaction(); | |
} | |
// Do we already have this fragment? | |
String name = makeFragmentName(container.getId(), position); | |
Fragment fragment = mFragmentManager.findFragmentByTag(name); | |
if (fragment != null) { | |
if (DEBUG) Log.v(TAG, "Attaching item #" + position + ": f=" + fragment); | |
mCurTransaction.attach(fragment); | |
} else { | |
fragment = getItem(position); | |
if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); | |
mCurTransaction.add(container.getId(), fragment, | |
makeFragmentName(container.getId(), position)); | |
} | |
if (fragment != mCurrentPrimaryItem) { | |
fragment.setMenuVisibility(false); | |
} | |
return fragment; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment