【问题标题】:Implementing 47degree android-swipelistview for swiping android ListViewItem实现47度android-swipelistview刷卡android ListViewItem
【发布时间】:2013-05-22 10:35:49
【问题描述】:

其实我的目标是在 android 中实现 ListViewItem Swipe。我已经尝试过了,stackoverflow 有几个例子可以让你的 ListViewSwipe。例子。

Simple swipe gesture to activity tutorial?

Show button in a list view on swiping one item from that list

有一点是每个人都在给出代码,没有人解释发生了什么。

然后我问了Android list view Right / Left swipes like call logs 的问题,@CommonsWare 用 SwipeListView 库回答了这个问题,该库的流程流畅,然后是公认的答案。接受的答案也很好,我目前只使用它。

这是图书馆http://www.androidviews.net/2013/03/swipelistview/ 哪个为您提供这样的列表视图

我已经尝试了超过 50 次来运行 github 上提供的示例应用程序 https://github.com/47deg/android-swipelistview-sample 但每次我都面临新问题。目前即将到来的例外是

05-22 15:35:19.392: E/AndroidRuntime(980): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.fortysevendeg.android.swipelistview.SwipeListView" on path: /data/app/com.fortysevendeg.android.swipelistview-2.apk

我不知道发生了什么我检查了构建路径,还包括库,在 stackoverflow 聊天中问了很多人但没有得到任何帮助。

实际上,在互联网上,我已经向这么多人询问过它的实现教程,但并没有一个单一的教程。所以我想知道是否有人使用过这个库,请写一个适当的答案如何预先使用它所以与我一起其他未来的读者也可以从中受益。

或者是否有任何其他库可以执行来实现这种功能。

正如@CommonsWare 所建议的那样。我已经给作者写了一封电子邮件,也写了一个使用它的教程。

【问题讨论】:

  • 你能知道如何使用它吗?我有类似的问题,无法找到任何东西:(
  • @Majid 不,我无法弄清楚直到日期
  • 我会发邮件给作者,希望他回复:(
  • @Majid 我大约 25 天前给他发了电子邮件,但他还没有回复。如果他回复您,请在此处分享解决方案。让每个人都能从中受益。
  • 今晚我给他发了电子邮件,但没有得到任何回复..我希望他回复我:(..好吧,如果我能找到任何东西,我会分享解决方案;)

标签: android listview swipe


【解决方案1】:

最后,我成功地将 Android-SwipeListView 库 47Degrees 集成到我自己的应用程序中。

像魅力一样工作。感谢 47Degrees 写出如此精彩的代码。

解决方案:

什么不起作用?!

在 res/values 中包含 JAR 作为依赖项和 attrs.xml 或将 SwipeListView 库作为项目中的 lib 依赖项引用都不起作用。

什么有效?!

在您的应用程序包中包含以下类。请务必将这些类中的包名更正为您的包名

  • SwipeListView.java
  • SwipeListViewListener.java
  • SwipeListViewListenerBase.java
  • SwipeListViewTouchListener.java

将以下 xml 包含到您的应用程序 res/values 文件夹中

  • attrs.xml

现在您可以按如下方式定义和使用 SwipeListView

<au.com.your.package.SwipeListView
        xmlns:swipe="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swipe_listview"
        android:listSelector="#00000000"
        android:layout_width="match_parent"
        android:layout_height="match_parent"        
        swipe:swipeFrontView="@+id/front"
        swipe:swipeBackView="@+id/back"
        swipe:swipeActionLeft="reveal"
        swipe:swipeActionRight="choice"
        swipe:swipeMode="both"
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeOpenOnLongPress="true"
        swipe:swipeAnimationTime="100"
        swipe:swipeOffsetLeft="50dp"
        swipe:swipeDrawableChecked="@drawable/item_selected"
        swipe:swipeDrawableUnchecked="@drawable/item_unselected"
   />

您可以使用的活动代码与example on SwipeListView github site 中显示的相同。

您需要更正上述代码中的一些导入。此外,您需要在项目中包含 NineOldAndroids by Jake Wharton 作为 lib 依赖项。

【讨论】:

  • 感谢它的帮助。但也需要 Nineoldandroids-2.4.0.jar 用于 SwipeListViewTouchListener 类,可在 GitHub 的 SwipeToDissmiss 项目中获得。我们可以下载并添加到我们的库中。项目文件夹并添加到构建路径。
【解决方案2】:

最简单的测试是将整个内容复制到项目中。我看到它在资源中只有 attr.xml,所以它不会那么难做,也不会让你的项目变脏。试试看。直接复制/粘贴到/src

这应该是一个 Android 库项目,您应该这样附加它。您遇到的错误有时会由于某些愚蠢的原因而发生,我不知道您何时在 /libs 中添加库(不需要以这种方式在 BuildPath 中引用)。

在这种特定情况下,该项目只有在您将其连接为库项目而不是 JAR 时才能工作。

希望这会有所帮助。

这个库也是一个 Maven 项目。你需要有 maven for android setup 才能构建它。或将其转换回常规项目。

【讨论】:

  • 先生,您能否详细解释一下“在这种特定情况下,该项目只有在您将其连接为库项目而不是 JAR 时才能工作。”。我会非常感谢你。
  • 是的。因此,具有资源的项目不能导出为 jar 文件并放入库中。它们需要作为库项目连接到您的 android 应用程序。developer.android.com/tools/projects/index.html。如果您使用的是eclipse,它非常简单。只需右键单击属性-> android 拥有您需要做的一切。
【解决方案3】:

正确引用所有库后,我将 XML 更改为引用 SwipeListView,如下所示:

 <main.java.com.fortysevendeg.android.swipelistview.SwipeListView
      xmlns:swipe="http://schemas.android.com/apk/res-auto"
      android:id="@+id/example_lv_list"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:listSelector="#00000000"
      swipe:swipeActionLeft="reveal"
      swipe:swipeActionRight="reveal"
      swipe:swipeAnimationTime="10"
      swipe:swipeBackView="@+id/back"
      swipe:swipeCloseAllItemsWhenMoveList="true"
      swipe:swipeFrontView="@+id/front"
      swipe:swipeMode="right"
      swipe:swipeOffsetLeft="80dip"
      swipe:swipeOffsetRight="80dip"
      swipe:swipeOpenOnLongPress="false" />

【讨论】:

【解决方案4】:

尝试将以下内容添加到 build.grandle

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}

【讨论】:

    【解决方案5】:

    我遇到了同样的问题。

    java.lang.ClassNotFoundException: Didn't find class "com.fortysevendeg.android.swipelistview.SwipeListView"
    

    要解决这个问题,您需要在 Properties > Android > Library > Add... 中导入库。 GDroid 的解决方案对我不起作用。

    提示1:将库复制到项目的同一工作区或文件夹中,eclipse 在导入其他文件夹中的项目库时出现问题。这个帖子帮我解决了这个问题:https://stackoverflow.com/a/5167294/2554730

    提示2:如果你正在寻找项目库来ecplise,因为到Android Studio的项目不工作,然后尝试在Android Studio中打开项目库,完成操作后你必须进入项目的文件夹并寻找

    gen-external-apklibs > com.fortysevendeg.android_swipelistview_1.0-20130701.103547-12

    这是 Eclipse 项目所在的文件夹。导入这个项目,然后粘贴到文件夹 libs(如果没有 libs 文件夹...创建一个)

    android-support-v4.jar 和 Nineoldandroids-2.4.0.jar

    这些 .jars 应该可以修复您的错误。

    【讨论】:

      猜你喜欢
      • 2013-11-19
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多