Android Fragment should be static's mistake to ask the boss to click is already mad!

in practice, follow the br that the book knocks out step by step.
call the replace method here to create an anonymous inner class. Ide has this error.
this method is contained in the following class

.
    class MyOnCheckedChangListener implements RadioGroup.OnCheckedChangeListener {

1. Try to change the class to static unsolvable
2. Redefining a public static inheritance fragment class to extract the above code snippet into the class also fails to report an error

log error:

     Caused by: java.lang.IllegalStateException: Fragment com.test.yu.player.activity.MainActivity.MyFragment must be a public static class to be  properly recreated from instance state.

just updated studio and got tired.

studio 3.3 android sdk 2.6 gradle 4.4


solves the problem of creating a new class in which an internal static class inherits Fragment
seems a bit silly, but the problem is solved


are you getting it a little wrong? no, no, no.


ask me the same question: how did you solve it?

Menu