膨胀相对布局时出错
Posted
技术标签:
【中文标题】膨胀相对布局时出错【英文标题】:Getting an error inflating relative layout 【发布时间】:2011-09-06 13:37:43 【问题描述】:基本上我已经编写了一个自定义小部件,它将在屏幕上显示 5 次,一个在另一个下,右侧是地图视图。我可以使用自定义小部件,但是当我尝试显示地图时,我收到了一些错误(见下文)
我不确定我在哪里出错了:S
09-06 14:27:49.085: ERROR/androidRuntime(28198): FATAL EXCEPTION: main
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): java.lang.RuntimeException: Unable to start activity ComponentInfoHartford.gps/Hartford.gps.MapCalculations: android.view.InflateException: Binary XML file line #2: Error inflating class RelitiveLayout
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.os.Looper.loop(Looper.java:123)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread.main(ActivityThread.java:3691)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at java.lang.reflect.Method.invokeNative(Native Method)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at java.lang.reflect.Method.invoke(Method.java:507)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at dalvik.system.NativeStart.main(Native Method)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class RelitiveLayout
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.Activity.setContentView(Activity.java:1657)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at Hartford.gps.MapCalculations.onCreate(MapCalculations.java:18)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): ... 11 more
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): Caused by: java.lang.ClassNotFoundException: android.view.RelitiveLayout in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/Hartford.gps-2.apk]
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-06 14:27:49.085: ERROR/AndroidRuntime(28198): ... 19 more
这是 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<RelitiveLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_
android:layout_
>
<Hartford.gps.GaugeView
android:id="@+id/gauge"
android:layout_
android:layout_
android:background="#ffffff"
android:antialias="true"
/>
<Hartford.gps.GaugeView
android:id="@+id/gauge2"
android:layout_
android:layout_
android:background="#ffffff"
android:antialias="true"
/>
<Hartford.gps.GaugeView
android:id="@+id/gauge3"
android:layout_
android:layout_
android:background="#ffffff"
android:antialias="true"
/>
<Hartford.gps.GaugeView
android:id="@+id/gauge4"
android:layout_
android:layout_
android:background="#ffffff"
android:antialias="true"
/>
<Hartford.gps.GaugeView
android:id="@+id/gauge5"
android:layout_
android:layout_
android:background="#ffffff"
android:antialias="true"
/>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_
android:layout_
android:clickable="false"
android:apiKey="0xO7eqfjJxqq5P_yfuU0_Wdi7Q4xPfRi95B_AYw"
/>
</RelitiveLayout>
【问题讨论】:
【参考方案1】:<RelitiveLayout xmlns:android="http://schemas.android.com/apk/res/android"
应该是“RelativeLayout”而不是“RelitiveLayout”
【讨论】:
是的,我不敢相信我没有看到!好吧,老实说,我有点松了一口气,我认为代码是有序的! :)【参考方案2】:您似乎有一个拼写错误 'RelitiveLayout' 。 我认为在这个类中 Hartford.gps.MapCalculations.onCreate(MapCalculations.java:18)
可能要搜索整个项目以查找错误在 Eclipse 中使用 ctrl+H 的位置。
【讨论】:
哇哦!日食(或我自己!)怎么没有意识到这一点!哈哈哈 在 XML 中拼写错误 如果这行得通。请设置答案,以便从未回答列表中删除此问题。 我还不行,时间还没到以上是关于膨胀相对布局时出错的主要内容,如果未能解决你的问题,请参考以下文章