0

您好我正在使用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 添加了所有必要的属性。任何帮助将不胜感激。

4

2 回答 2

0

我无法使用 libs/ 中的 swipelistview jar 令人满意地解决这个问题,所以我只是将源链接到作为外部库项目的源,并且效果很好。

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

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

我怀疑 jar 方法的问题是滑动列表初始化程序在编译时无法访问您的项目资源,因此当它尝试拉入这些资源(从您的本地 attrs.xml 文件)时,事情会变得一团糟 - 参考资料不要指向 /your/ 资源,因为编译 jar 时,这些资源不存在。

无论如何,希望这有助于推动事情的发展。

于 2013-05-29T20:30:36.843 回答
0

查看我关于开始使用 swipelistview 的帖子:http: //modewagon.wordpress.com/2013/09/16/getting-started-with-swipelistview/

于 2013-09-16T06:16:41.617 回答