The method getFragmentManager() is undefined for t

2019-02-21 17:41发布

问题:

Since I've been using my code, I used fragments.

To do so, I have an activity calling a fragment using a fragment by tag :

FluxListFragment FLF = (FluxListFragment) getFragmentManager().findFragmentByTag(FRAG_LIST);

But since today, getFragmentManager seems to be unrecognized. It says :

"The method getFragmentManager() is undefined for the type FluxMainActivity"

Is the problem coming from the build target ? (I put Android 3.0)

Here is the code :

public Class FluxMainActivity extends Activity {

@override
public void onCreate(Bundle saveInstanceState)
{
    super.onCreate();
    setContentView(R.layout.main);
    FluxListeFragment FLF = (FluxListeFragment)getFragmentManager().findFragmentByTag(FRAG_LISTE);    
}

}

The method should be linked to FluxListeFragment and not FluxMainActivity ! I think the cast is incorrect.

回答1:

Problem solved.

The project target was in API 11, but it contained 2 libraries with one of them in target API 8.