EDIT: PROBLEM SOLVED. SEE COMMENTS BELOW...
I'm trying to implement an OnPageChangeListener to my ViewPager. I have issues determining the active fragment (name the class myFragment). Somewhere in my TabsAdapter the Fragment is set:
@Override
public Fragment getItem(int position)
{
TabInfo info = mTabs.get(position);
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
}
I think, that info.clss.getName() is like myFragment.class.getName(). If i call this:
FragmentManager fm = getSupportFragmentManager();
then myfragment.class.getName() appears in properties. But if i call this:
Fragment test = fm.findFragmentByTag(myfragment.class.getName());
test is null.
See what FM is at runtime:
fm FragmentManagerImpl (id=830007952696)
mActive ArrayList (id=830007771376)
array Object[12] (id=830008021856)
[0] fragment1 (id=830007965416)
[1] myFragment (id=830008076232)
[2] null
...
size 2
mActivity tabActivity (id=830007948592)
mAdded ArrayList (id=830007781264)
mAvailBackStackIndices null
mAvailIndices null
mBackStack null
mBackStackChangeListeners null
mBackStackIndices null
mCreatedMenus null
mCurState 5
mDestroyed false
mExecCommit FragmentManagerImpl$1 (id=830007953504)
mExecutingActions false
mHavePendingDeferredStart false
mNeedMenuInvalidate false
mNoTransactionsBecause null
mPendingActions ArrayList (id=830007908880)
mStateArray null
mStateBundle null
mStateSaved false
mTmpActions Runnable[1] (id=830007783384)
Another issue is, that the tab indicator isn't set to the active tab.