ListFragment Support Library GetSupportFragmentManager undefined

前端 未结 2 900
深忆病人
深忆病人 2021-02-04 12:26

I have a list Fragment (importing the v4 support library, build target is 2.3.3 api 11) and the following problem in my code that was working fine when the target was 3.0 and I

相关标签:
2条回答
  • You should use

    getActivity().getSupportFragmentManager()
    

    If that is still giving you problems, then makre sure that your Activity extends FragmentActivity.

    If that is still giving you problems,

    1. Delete all of your imports,
    2. Re-import with Ctrl + Shift + O, and
    3. On every name clash, make sure you import from support.v4.*, not android.*.
    0 讨论(0)
  • 2021-02-04 13:12

    You have to make sure that when you extend Fragment that you are extending the Fragment that is in the v4 package space. Check your imports for Fragment, FragmentActivity, etc, and if you see them imported WITHOUT .v4 in the package name, then it is wrong.

    Also, if you set the android library for the project to be 2.3 and not 4.0.x then you'll quickly see if you are using the incorrect classes, because you'll get compile errors, which can be fixed by using the v4 classes from the android support jar (which hopefully you've included in your project as well)

    0 讨论(0)
提交回复
热议问题