0

根据https://github.com/xamarin/monodroid-samples/tree/master/SlidingMenu ,我在我的应用程序中使用了 SlidingMenu 库。我在 android 4.0+ 上成功构建和运行应用程序,但在 android 2.2 上运行应用程序失败,但我看到了 android 滑动菜单https://github.com/jfeinstein10/SlidingMenu,它支持从 android 2.1。

这是错误代码:

at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00088>
at Com.Slidingmenu.Lib.App.SlidingActivity.SetBehindContentView (int) <0x00237>
at regrecall.HomeActivity.OnCreate (Android.OS.Bundle) <0x00097>
at Com.Slidingmenu.Lib.App.SlidingActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005f>
at (wrapper dynamic-method) object.ffcb4990-4b21-40ac-9622-acbf3c40174b (intptr,intptr,intptr) <0x00043>

  --- End of managed exception stack trace ---
android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.ListView
    at android.view.LayoutInflater.createView(LayoutInflater.java:513)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    at com.slidingmenu.lib.app.SlidingActivity.setBehindContentView(SlidingActivity.java:83)
    at regrecall.HomeActivity.n_onCreate(Native Method)
    at regrecall.HomeActivity.onCreate(HomeActivity.java:32)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at android.widget.ListView.<init>(ListView.java:153)
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
    at android.view.LayoutInflater.createView(LayoutInflater.java:500)
    ... 22 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/common_background.png from drawable resource ID #0x7f020081: .xml extension required
at android.content.res.Resources.loadColorStateList(Resources.java:1824)
    at android.content.res.TypedArray.getColor(TypedArray.java:319)
    at android.widget.AbsListView.<init>(AbsListView.java:554)
    at android.widget.ListView.<init>(ListView.java:157)
    ... 26 more

忘了我不能复制整个日志,因为另一台机器上的日志无法连接到网络。我分析了这个日志,在SldingMenuActivity的onCreate方法处crash了,在activity的后面视图创建listview失败,但是在android 4.0+上可以运行,太奇怪了。

我发现的问题:我的listview在android 2.2上不能infalte,即使我的布局在下面这么简单

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/Home_MenuList"
       />
</LinearLayout>
4

1 回答 1

0

如果您查看Caused byStack Trace 中的部分,它会告诉您:

原因:android.content.res.Resources$NotFoundException:来自可绘制资源 ID #0x7f020081 的文件 res/drawable/common_background.png:需要 .xml 扩展名

该资源有问题,是否有任何人在ListViewItem使用该资源Drawable

于 2013-07-09T09:30:12.107 回答