根据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方法中崩溃了,它无法为活动的后台视图创建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>
答案 0 :(得分:0)
如果您查看堆栈跟踪中的Caused by
部分,它会告诉您:
引起:android.content.res.Resources $ NotFoundException:来自可绘制资源ID的文件res / drawable / common_background.png#0x7f020081:需要.xml扩展名
该资源有问题,使用此资源ListViewItem
的任何Drawable
是什么?