I have a problem using a class that extends android.view.View, which is odd because I am doing the same thing in two different projects, and only in one of them is the problem.
Both projects have a class that says: public class ClassName extends View
.
But for one of them, this line is underlined in red, and the above message
"There is no default constructor in the android.view.View constructor
I do not know why you have this problem, and the other is not. Naturally, they are not the same classes, but both of them simultaneously expand the view. I thought this would be a common problem, but I can't find anything about it through a google search, so I ask here. Thanks for any help you can give!
EDIT:
The comments made me check again, and, of course, the class with an error does not have a constructor defined in its class. I'm curious that although I went and determined the constructor, it still threw the same error until it added the parameters (context context, AttributeSet attrs), and the string "super (context, attrs)" was added to the constructor. I added them because they were present in the constructor of the working class. So the working version
public DrawingActivity(Context context, AttributeSet attrs) { super(context,attrs); }
My new question is what exactly does this do. This was taken from a class that did not have an error, and this version was originally copied from a textbook and never thought about it.
source share