Custom View doesn't use View 2 or 3 argument constructors

I know what I can do, as it warns me; create a constructor like 2 or 3 arguments.

However, it CustomView

belongs to a third party SDK, which is final

, so I feel I should use this one to take full advantage of the SDK. Anyway, there is no way to expand final CustomView

.

Is there a workaround?

On a side note I'm trying to use Metaio .MetaioSurfaceView


Below is the logcat message right after the crash:

A/WTF(18270): Unable to start activity ComponentInfo{com.suzi.application/com.suzi.application.CustomActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.metaio.sdk.MetaioSurfaceView
A/WTF(18270): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.suzi.application/com.suzi.application.CustomActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.metaio.sdk.MetaioSurfaceView
A/WTF(18270):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
A/WTF(18270):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
A/WTF(18270):   at android.app.ActivityThread.access$700(ActivityThread.java:165)
A/WTF(18270):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
A/WTF(18270):   at android.os.Handler.dispatchMessage(Handler.java:99)
A/WTF(18270):   at android.os.Looper.loop(Looper.java:176)
A/WTF(18270):   at android.app.ActivityThread.main(ActivityThread.java:5455)
A/WTF(18270):   at java.lang.reflect.Method.invokeNative(Native Method)
A/WTF(18270):   at java.lang.reflect.Method.invoke(Method.java:525)
A/WTF(18270):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
A/WTF(18270):   at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
A/WTF(18270):   at dalvik.system.NativeStart.main(Native Method)

      

+3


source to share


1 answer


if you have a custom view and the customView has only one type of constructor like default constructor

when you add custom view to xml than xml wants   CustomView(Context context, AttributeSet attrs)

CustomView(Context context, AttributeSet attrs, int defStyle)

 this type of constructor.



and if your custom view belongs to third party lib, then you can only add default Java code like new CustomView();

+6


source







All Articles