Android 错误:此类应提供默认构造函数(没有参数的公共构造函数)[可实例化]
在调试模式下编译时一切正常。但在版本配置中编译时,出现以下错误: 错误:此类应提供默认构造函数(没有参数的公共构造函数)(tb.lo.MyTabFactory)[可实例化] 代码如下:Android 错误:此类应提供默认构造函数(没有参数的公共构造函数)[可实例化],android,android-studio,android-context,Android,Android Studio,Android Context,在调试模式下编译时一切正常。但在版本配置中编译时,出现以下错误: 错误:此类应提供默认构造函数(没有参数的公共构造函数)(tb.lo.MyTabFactory)[可实例化] 代码如下: public class MyTabFactory implements TabContentFactory { private final Context mContext; public MyTabFactory(Context context) { mContext = c
public class MyTabFactory implements TabContentFactory {
private final Context mContext;
public MyTabFactory(Context context) {
mContext = context;
}
public View createTabContent(String tag) {
View v = new View(mContext);
v.setMinimumWidth(0);
v.setMinimumHeight(0);
return v;
}
}
如错误所示,添加以下构造函数。它应该会起作用
public MyTabFactory() {
}
错误消息清楚地告诉您要做什么:
这个类应该提供一个默认构造函数(一个没有参数的公共构造函数)