2

出于某种原因,我在使用 HoloEverywhere 时遇到了这个错误。我的应用程序在创建时崩溃,并且我的 xml 布局在 3.0 以下时不显示。这是我的 xml 错误。

Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\color\secondary_text_holo_light.xml
Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\drawable\background_cache_hint_selector_holo_light.xml
Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\color\primary_text_holo_light.xml
Exception details are logged in Window > Show View > Error Log

这是我的日志。它引用了我活动的 onCreate 第 57 行的错误。第 57 行扩充了 xml 文件。这只发生在 HoloEverywhere 上。请帮忙!

12-09 03:01:20.893: E/AndroidRuntime(327): FATAL EXCEPTION: main
12-09 03:01:20.893: E/AndroidRuntime(327): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sample/com.example.sample.CourseListActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.os.Looper.loop(Looper.java:123)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-09 03:01:20.893: E/AndroidRuntime(327):  at java.lang.reflect.Method.invokeNative(Native Method)
12-09 03:01:20.893: E/AndroidRuntime(327):  at java.lang.reflect.Method.invoke(Method.java:521)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-09 03:01:20.893: E/AndroidRuntime(327):  at dalvik.system.NativeStart.main(Native Method)
12-09 03:01:20.893: E/AndroidRuntime(327): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:278)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:263)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:258)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:253)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.app.Activity.setContentView(Activity.java:242)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.example.sample.CourseListActivity.onCreate(CourseListActivity.java:57)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-09 03:01:20.893: E/AndroidRuntime(327):  ... 11 more
12-09 03:01:20.893: E/AndroidRuntime(327): Caused by: java.lang.ClassNotFoundException: Could not find class: fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.onCreateView(LayoutInflater.java:318)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
12-09 03:01:20.893: E/AndroidRuntime(327):  ... 21 more
4

3 回答 3

0

看起来这已在 HoloEverywhere 1.4.1 中修复:https ://github.com/ChristopheVersieux/HoloEverywhere/issues/

更新到 1.4.1 是否为您解决了问题?

于 2013-01-02T19:37:51.517 回答
0

错误日志说

Could not find class: fragment

片段需要 API 级别 11 或更高 :)

如果你想Fragments在 API < 11 上使用,你需要为此使用Support Library包。

于 2012-12-09T09:40:26.793 回答
0

尝试以编程方式添加您的片段。也就是说,您的 xml 应该只有布局“内容”和 onCreate:

if (savedInstanceState == null) {
    // Add the fragment on initial activity setup
    MyFragment myFragment = new MyFragment();
    getSupportFragmentManager().beginTransaction().
         add(R.id.content, myFragment).commit();
}
于 2013-01-25T03:11:31.487 回答