For some reason, Eclipse doesn't like the call to super(context, attrs, defStyle), yet it's happy with the other super calls. The error is "The constructor LinearLayout(Context, AttributeSet, int) is undefined".
I don't think the problem is with this code itself, but something else in the project's settings or something, since I adapted almost identical code from an example that did the same thing but for a RelativeLayout, which ran fine on my Eclipse setup in a test project.
Please Help :)
public class MyLinearLayout extends LinearLayout {
public MyLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
myInit();
}
public MyLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
myInit();
}
public MyLinearLayout(Cont开发者_运维问答ext context, int checkableId) {
super(context);
myInit();
}
According to these javadocs the error is completely correct.
LinearLayout
does not have that constructor. These are the two valid constructors:
LinearLayout(Context context)
LinearLayout(Context context, AttributeSet attrs, Map inflateParams)
http://developer.android.com/reference/android/widget/LinearLayout.html
According to the developer site, the LinearLayout(context, attrs, defStyle) constructor is only available in API version 11, so it won't work in earlier versions.
精彩评论