0

我成功地在我的代码中创建了 jar 库,但是在我的 xml 文件中它调用

 06-08 18:55:23.715: E/AndroidRuntime(13218): java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line #6: Error inflating class android.jar.com.jjoe64.graphview.BarGraphView

例外。jar 文件在这里github-jjoe64/GraphView

 06-08 19:46:22.023: E/AndroidRuntime(19764): FATAL EXCEPTION: main
06-08 19:46:22.023: E/AndroidRuntime(19764): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zxl.Timetable/com.zxl.Timetable.ui.CurriculumAllInfo}: android.view.InflateException: Binary XML file line #6: Error inflating class com.jjoe64.graphview.BarGraphView
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread.access$600(ActivityThread.java:153)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.os.Looper.loop(Looper.java:137)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread.main(ActivityThread.java:5226)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at java.lang.reflect.Method.invokeNative(Native Method)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at java.lang.reflect.Method.invoke(Method.java:511)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at dalvik.system.NativeStart.main(Native Method)
06-08 19:46:22.023: E/AndroidRuntime(19764): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.jjoe64.graphview.BarGraphView
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.createView(LayoutInflater.java:596)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.Activity.setContentView(Activity.java:1881)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at com.zxl.Timetable.ui.CurriculumAllInfo.onCreate(CurriculumAllInfo.java:39)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.Activity.performCreate(Activity.java:5104)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
06-08 19:46:22.023: E/AndroidRuntime(19764):    ... 11 more
06-08 19:46:22.023: E/AndroidRuntime(19764): Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
06-08 19:46:22.023: E/AndroidRuntime(19764):    at java.lang.Class.getConstructorOrMethod(Class.java:460)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at java.lang.Class.getConstructor(Class.java:431)
06-08 19:46:22.023: E/AndroidRuntime(19764):    at android.view.LayoutInflater.createView(LayoutInflater.java:561)
06-08 19:46:22.023: E/AndroidRuntime(19764):    ... 22 more

@jjoe64

4

2 回答 2

1

创建文件夹

在您的项目中并在其中添加该 jar 文件

右键单击该jar文件

-->构建路径-->添加到构建路径

于 2013-06-19T12:02:56.120 回答
0

您尝试在布局文件中使用的View需要实现采用 aContext和 an的两参数构造函数AttributeSet,因为这是布局充气器使用的构造函数。您View没有,因此它不能在布局 XML 资源中使用。

于 2013-06-08T11:54:35.127 回答