子类的警告
Custom view My_Marker_View is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) less... (Ctrl+F1)
generate signed APK的时候报错
Error:Error: This class should provide a default constructor (a public constructor with no arguments) public class My_Marker_View extends MarkerView {
private static ArrayList<String> list;
private TextView tvContent0;
private TextView tvContent;
public My_Marker_View(Context context, int layoutResource) {
super(context,layoutResource); tvContent= (TextView) findViewById(R.id.tvContent);
}
public static My_Marker_View newInstance(Context context, int layoutResource,ArrayList<String> x_data) {
My_Marker_View myMarkerView = new My_Marker_View(context,layoutResource);
list=x_data;
return myMarkerView;
}
@Override
public void refreshContent(Entry e, Highlight highlight) { if (e instanceof CandleEntry) { CandleEntry ce = (CandleEntry) e; tvContent.setText(Utils.formatNumber(ce.getHigh(), 1, true).replace(",","."));
} else {
tvContent.setText(Utils.formatNumber(e.getY(),1,true).replace(",","."));
} super.refreshContent(e, highlight);
} @Override
public MPPointF getOffset() {
return new MPPointF(-(getWidth() / 2), -getHeight());
}
}父类没有无参构造函数,我这个子类是不是要自己手写一个,该怎么写?
Custom view My_Marker_View is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) less... (Ctrl+F1)
generate signed APK的时候报错
Error:Error: This class should provide a default constructor (a public constructor with no arguments) public class My_Marker_View extends MarkerView {
private static ArrayList<String> list;
private TextView tvContent0;
private TextView tvContent;
public My_Marker_View(Context context, int layoutResource) {
super(context,layoutResource); tvContent= (TextView) findViewById(R.id.tvContent);
}
public static My_Marker_View newInstance(Context context, int layoutResource,ArrayList<String> x_data) {
My_Marker_View myMarkerView = new My_Marker_View(context,layoutResource);
list=x_data;
return myMarkerView;
}
@Override
public void refreshContent(Entry e, Highlight highlight) { if (e instanceof CandleEntry) { CandleEntry ce = (CandleEntry) e; tvContent.setText(Utils.formatNumber(ce.getHigh(), 1, true).replace(",","."));
} else {
tvContent.setText(Utils.formatNumber(e.getY(),1,true).replace(",","."));
} super.refreshContent(e, highlight);
} @Override
public MPPointF getOffset() {
return new MPPointF(-(getWidth() / 2), -getHeight());
}
}父类没有无参构造函数,我这个子类是不是要自己手写一个,该怎么写?
在xml文件里会默认调
public View(Context context, AttributeSet attrs) {
super(context, attrs);
}
这个构造函数
如果是在代码里动态添加控件的话应该不会有问题吧?