android - 如何将我的 listView 转换为动态 ListView ?我指的是 http ://nhaarman. github.io/ListViewAnimations/#dynamiclistview

标签 android listview

我正在尝试使用这个:lib当用户滑动时删除我的列表项。但我似乎不知道如何将我现有的 listView 转换为 DynamicListView。我已经阅读了给出的说明,它只是说要在 xml 布局中添加一些代码以将 listView 转换为 DynamicListView,但是我应该把代码放在哪里?在哪个xml文件中?我不知道。任何帮助将不胜感激。

这是维基中给出的内容:

To use the DynamicListView, include the following in your xml layout:

<com.nhaarman.listviewanimations.itemmanipulation.DynamicListView
        android:id="@+id/dynamiclistview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

最佳答案

看来您需要将当前列表设为

<com.nhaarman.listviewanimations.itemmanipulation.DynamicListView
        android:id="@+id/dynamiclistview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

并添加

描述的功能
MyAdapter myAdapter = new MyAdapter();
AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(myAdapter);
animationAdapter.setAbsListView(mListView);
mListView.setAdapter(animationAdapter);

创建您自己的适配器以插入您现有的 ListView 实现。所以我想知道,如果您有自己的适配器设置,您没有提供任何代码吗?因此,主要是您的 ListView 必须符合 xml“@+id/dynamiclistview”才能运行。如果您已经构建了一个适配器,我建议扩展那里的实现,并且只提供滑动和删除功能的方法。

编辑:

请注意这很重要 <com.nhaarman.listviewanimations.itemmanipulation.DynamicListView 您已经实现并正确导入了库。 (有问题问)

关于android - 如何将我的 listView 转换为动态 ListView ?我指的是 http ://nhaarman. github.io/ListViewAnimations/#dynamiclistview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30902384/

相关文章:

android - 图像尺寸和移动设备以及 dpi

java - mKeyStore?.getKey ("default_key", null) 在 Kotlin 中获取 null

listview - 如何通过代码使ListView VCL折叠/展开?

java - 带有 ListView 的 XYPlot 具有黑色背景而不是透明背景

java - 调用一个函数

android - 从空白 Activity 启动抽屉导航 Activity 时应用程序崩溃

android - Listview 不同步滚动逻辑

android - 如何将数据搜索到 json ListView 中?

java - 如何在 ArrayAdapter 中一次更新一个 View ?

java - 如何计算轮廓opencv内的非零像素