3
我知道我可以做,因为警告指示我;创建2或3参数View构造函数。自定义视图自定义视图不使用2或3参数视图构造函数
但是,CustomView
来自第三方SDK,它是final
,所以我觉得我必须用这个来充分利用SDK。总之,没有机会延伸final CustomView
。
有什么解决方法吗?
在附注中,我试图使用的视图是 MetaioSurfaceView
由Metaio。
下面是大跌之后的logcat的消息:
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)
所以除了我必须处理通过硬编码的布局东西只添加默认的构造函数,缺少的构造函数(具有AttributeSet参数)不是邪恶的? – Suzi 2014-11-01 06:15:50
哈哈是的,在每个第三方的自定义视图中至少应该有三个构造函数 – 2014-11-01 06:20:27
很好听,没有其他问题。谢谢! – Suzi 2014-11-01 06:29:09