创建View时候,写三个构造函数
public MyWidgetView(Context context) {
super(context);
}
public MyWidgetView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyWidgetView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
2016.04.18
error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.launcher/com.android.launcher2.Launcher}: android.view.InflateException: Binary XML file line #39: Error inflating class com.android.launcher2.MyWidgetView
包名与xml中default_workspace.xml中包名一致