错误充气类片段找不到类android.view.fragment但我包括兼容性库? [英] Error inflating class fragment class not found android.view.fragment but I am including the compatability library?

查看:158
本文介绍了错误充气类片段找不到类android.view.fragment但我包括兼容性库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我虽然我使用兼容性库看到了android.view.fragment一类未发现异常。编译罚款,但崩溃。是否有另一个我应该使用时pre 3.0包?我已经改变了所有片段类android.support.v4.app.Frament但它仍然崩溃的原因是什么布局。我的SDK是4.03,但设备是2.3。

下面是布局

 <?XML版本=1.0编码=UTF-8&GT?;
 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=横向>
<片段
    机器人:ID =@ + ID / frag_series
    机器人:layout_width =200dip
    机器人:layout_height =match_parent
    机器人:layout_marginTop =机器人:ATTR / actionBarSize
    类=com.authorwjf.hello_fragments.ListFrag/>
<片段
    机器人:ID =@ + ID / frag_capt
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    类=com.authorwjf.hello_fragments.DetailFrag/>
< / LinearLayout中>

LogCat中:

  14 08-08:53:21.644:E / AndroidRuntime(13056):android.view.InflateException:二进制XML文件,6号线:错误充气类片段产生的原因
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-08 14:53:21.644:E / AndroidRuntime(13056):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.app.Activity.setContentView(Activity.java:1647)
08-08 14:53:21.644:E / AndroidRuntime(13056):在com.authorwjf.hello_fragments.Main.onCreate(Main.java:11)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-08 14:53:21.644:E / AndroidRuntime(13056):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-08 14:53:21.644:E / AndroidRuntime(13056):... 11个
08-08 14:53:21.644:E / AndroidRuntime(13056):抛出java.lang.ClassNotFoundException:致android.view.fragment装载机dalvik.system.PathClassLoader [/data/app/com.authorwjf.hello_fragments-2 .apk文件]
08-08 14:53:21.644:E / AndroidRuntime(13056):在dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)


解决方案

做相同的布局XML:

 < android.support.v4.app.Fragment />

此外,注意大小写。

I am seeing a class not found exception for android.view.fragment although I am using the compatibility library. Compiles fine but crashes. Is there another package that I should use when pre 3.0? I already changed all fragment classes to android.support.v4.app.Frament but it still crashes because of what is in the layout. My SDK is 4.03 but device is 2.3.

Here is layout

    <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
    android:id="@+id/frag_series"
    android:layout_width="200dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.authorwjf.hello_fragments.ListFrag" />
<fragment
    android:id="@+id/frag_capt"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.authorwjf.hello_fragments.DetailFrag" />
</LinearLayout>

LogCat:

08-08 14:53:21.644: E/AndroidRuntime(13056): Caused by: android.view.InflateException:     Binary    XML file line #6: Error inflating class fragment
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.Activity.setContentView(Activity.java:1647)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at com.authorwjf.hello_fragments.Main.onCreate(Main.java:11)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-08 14:53:21.644: E/AndroidRuntime(13056):    ... 11 more
08-08 14:53:21.644: E/AndroidRuntime(13056): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.authorwjf.hello_fragments-2.apk]
08-08 14:53:21.644: E/AndroidRuntime(13056):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)

解决方案

Do the same in your layout XML:

<android.support.v4.app.Fragment />

Also, note the capitalization.

这篇关于错误充气类片段找不到类android.view.fragment但我包括兼容性库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆