Reputation: 3
I try to use FragmentActivity with single Fragment without viewpager and others.
I need the tag value from Fragment with the getTag method...
My code in onCreate of FragmentActivity :
// launch splash screen fragment
Fragment fragment = SplashScreenFragment.newInstance();
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
And when SplashScreenFragment is onCreateView, getTag() method return null in fragment..
I don't understand this .. I don't use Fragment attribut in XML layout, that is a reason ?
EDIT ::
I need tag to execute this code :
this.mSplashScreenFragment = (SplashScreenFragment) mMainFragmentActivity.getSupportFragmentManager().findFragmentByTag(tag);
mSplashScreenFragment after this line is null ..
Thank you for help !
Upvotes: 0
Views: 2979
Reputation: 1352
For ability to access fragment tag you should use
FragmentTransaction.add(int containerViewId, Fragment fragment, String tag)
method when you want to add fragment. In other words you should first set this tag from anywhere
Upvotes: 1