If I have a class, let’s say, extended from DialogFragment and define custom constructor for it, why should I define a default one? If I wouldn’t I get the error message if runtime change occurs.
If I have a class, let’s say, extended from DialogFragment and define custom constructor
Share
I suspect the problem is that in Java, the compiler creates a parameterless constructor for you unless you specify one yourself. If something within Android requires a parameterless constructor, then either you need to not declare any constructors yourself or you need to explicitly declare a parameterless one.
From section 8.8.9 of the Java Language Spec:
Does that make things clear? I don’t know enough about Android to know why you need a parameterless constructor, but presumably it’s so that instances can be created via reflection without specifying any arguments for constructor parameters.