android-swipelistview中的android.view.InflateException

时间:2013-04-12 07:33:21

标签: android android-listview

您好我正在使用SwipeListView库。我收到错误

04-12 12:53:47.189: E/AndroidRuntime(15197): FATAL EXCEPTION: main
04-12 12:53:47.189: E/AndroidRuntime(15197): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.emr/com.example.emr.EmrLauncher}: android.view.InflateException: Binary XML file line #12: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.os.Looper.loop(Looper.java:137)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread.main(ActivityThread.java:4424)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.reflect.Method.invokeNative(Native Method)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.reflect.Method.invoke(Method.java:511)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at dalvik.system.NativeStart.main(Native Method)
04-12 12:53:47.189: E/AndroidRuntime(15197): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.createView(LayoutInflater.java:606)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.example.emr.EmrLauncher.onCreate(EmrLauncher.java:59)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.Activity.performCreate(Activity.java:4465)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-12 12:53:47.189: E/AndroidRuntime(15197):    ... 11 more
04-12 12:53:47.189: E/AndroidRuntime(15197): Caused by: java.lang.reflect.InvocationTargetException
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.reflect.Constructor.constructNative(Native Method)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-12 12:53:47.189: E/AndroidRuntime(15197):    ... 23 more
04-12 12:53:47.189: E/AndroidRuntime(15197): Caused by: java.lang.NumberFormatException: Invalid int: "@2131427340"
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.Integer.invalidInt(Integer.java:138)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.Integer.parse(Integer.java:375)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at java.lang.Integer.parseInt(Integer.java:366)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at android.content.res.TypedArray.getInt(TypedArray.java:254)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.fortysevendeg.android.swipelistview.SwipeListView.init(SwipeListView.java:164)
04-12 12:53:47.189: E/AndroidRuntime(15197):    at com.fortysevendeg.android.swipelistview.SwipeListView.<init>(SwipeListView.java:134)
04-12 12:53:47.189: E/AndroidRuntime(15197):    ... 26 more

这是我的xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res/com.example.emr"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".EmrLauncher" >

    <com.fortysevendeg.android.swipelistview.SwipeListView
        xmlns:swipe="http://schemas.android.com/apk/Location"
        android:id="@+id/emrlist"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:listSelector="#00000000"
        app:swipeActionLeft="reveal"
        app:swipeBackView="@+id/back"
        app:swipeCloseAllItemsWhenMoveList="true"
        app:swipeFrontView="@+id/front"
        app:swipeMode="both"
        app:swipeOffsetLeft="40dp"
        app:swipeOffsetRight="40dp"
        app:swipeOpenOnLongPress="true" />

</RelativeLayout>

我也在使用actionbar sherlock库。我已经为swipelistview添加了所有必要的attr。任何帮助将非常感谢。

2 个答案:

答案 0 :(得分:0)

我无法使用libs /中的swipelistview jar令人满意地解决这个问题,因此我只是将源链接到外部库项目,并且工作正常。

在项目的project.properties中你需要这样的东西(假设你的构建环境使用了ant - 如果不是,那么eclipse也有类似的方法):

android.library.reference.1=../ThirdParty/android-swipelistview

我怀疑jar方法的问题是刷卡列表初始化程序在编译时无法访问项目的资源,所以当它试图引入这些资源时(从本地attrs.xml文件中),它会搞砸 - 引用不指向/ your / resources,因为在编译jar时,这些资源不存在。

无论如何,希望这有助于让事情发生变化。

答案 1 :(得分:0)