Can't find fragment by tag

Viewed 9227

I'm using support package v4.

mFragmentManager = getSupportFragmentManager();

FragmentTransaction ft = mFragmentManager.beginTransaction();
ft.add(R.id.fragContainer1, new ModelListFragment(), FRAG_MODEL_LIST);
ft.add(R.id.fragContainer2, new TrimListFragment(), FRAG_TRIM_LIST);
ft.commit();

Fragment fragment = mFragmentManager.findFragmentByTag(
            MainActivity.FRAG_MODEL_LIST);
Log.d("MY", "found fragment: " + (fragment != null));

Always returns "found fragment: false". I'm missing something really obvious here, what is it?

2 Answers
Related