Android 自定义控件时出现: Caused by: java.lang.NoSuchMethodException
来源:互联网 发布:英语词汇记忆 知乎 编辑:程序博客网 时间:2024/05/17 06:34
错误日志:
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class sourceforge.titlelan.VisualizerView at android.view.LayoutInflater.createView(LayoutInflater.java:606) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at android.view.LayoutInflater.inflate(LayoutInflater.java:400) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) at android.app.Activity.setContentView(Activity.java:1943) at sourceforge.titlelan.MainActivity.onCreate(MainActivity.java:31) at android.app.Activity.performCreate(Activity.java:5245) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249) at android.app.ActivityThread.access$800(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5052) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] at java.lang.Class.getConstructorOrMethod(Class.java:472) at java.lang.Class.getConstructor(Class.java:446) at android.view.LayoutInflater.createView(LayoutInflater.java:571) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at android.view.LayoutInflater.inflate(LayoutInflater.java:400) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) at android.app.Activity.setContentView(Activity.java:1943) at sourceforge.titlelan.MainActivity.onCreate(MainActivity.java:31) at android.app.Activity.performCreate(Activity.java:5245) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249) at android.app.ActivityThread.access$800(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5052) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) at dalvik.system.NativeStart.main(Native Method)上面的VisualizerView是我自定义的控件,而控件只有下面一个构造方法而已
public VisualizerView(Context context) { super(context); init(); }解决方案:
上面的构造方法应该有两个:
public VisualizerView(Context context) { this(context, null); } public VisualizerView(Context context, AttributeSet attrs) { super(context, attrs); init(); }
0 0
- Android 自定义控件时出现: Caused by: java.lang.NoSuchMethodException
- Caused by: java.lang.NoSuchMethodException
- 自定义View:关于Caused by: java.lang.NoSuchMethodException异常
- 自定义View:Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context,
- Caused by: java.lang.NoSuchMethodException: false [class android.view.View]
- Caused by: java.lang.NoSuchMethodException: xxx [class android.view.View]
- Caused by: java.lang.NoSuchMethodException: callDrawGLFunction [long]
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androi
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androi
- Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.
- 使用反射时出现java.lang.NoSuchMethodException
- 启动Tomcat时出现java.lang.NoSuchMethodException:
- Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
- mysql interactive_timeout wait_timeout区别
- TensorFlow入门篇之简介
- 关于select()
- [MySQL] 生产环境MySQL数据库事务一直在RUNNING
- ubuntu下全自动创建Redis集群脚本
- Android 自定义控件时出现: Caused by: java.lang.NoSuchMethodException
- 关于 select()函数
- 在html中一个汉字需要多少个nbsp来填充?
- RESTful API 设计最佳实践
- SDAutoLayout:比masonry更简单易用的自动布局库
- ssh-keygen生成两个key pair分别用于链接公司gitlab和自己的github库
- 客户端短视频拍摄、上传、下载,播放完整方案
- ubuntu全自动创建Redis集群脚本slaveof
- Activiti工作流之异常处理一