I want to extend Chronometer class and add my code.
How I could do it? I tried, but I can't get Chronometer constructor with View field. I get an exception, it is obvious:
...
android.view.InflateException: Binary XML file line #26: Binary XML file line #26: Error inflating class com.mantas.test.ChronometerV2
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
...
My code:
public class ChronometerV2 extends Chronometer{
public ChronometerV2(Contex context){
super(contex);
}
}
and initiation:
ChronometerV2 c2 = findViewById(R.id.chronometerv2);
I am passing View here, but Chronometer only has constructor with Context field. How to do it?
Add this constructor:
public ChronometerV2(Context context, AttributeSet attrs) {
super(context, attrs);
}