Fragment activity crashes on screen rotate

前端 未结 5 621
刺人心
刺人心 2021-01-01 18:22

I have a simple fragment activity. In the onCreate() method, I simply add a fragment. The code is posted below. However, each time I rotate the screen, system will call onCr

5条回答
  •  渐次进展
    2021-01-01 18:57

    Well, as you error says, something is wrong with your MyFragment class. Make sure you have something like:

    public class MyFragment extends Fragment
    

    when declaring your fragment class. Also, you shouldn't have any constructor in the class. So make sure that you don't have one.

    If you post the code for your Fragment class we might be able to help you better.

提交回复
热议问题