android – 拖放不能在nhaarman的ListviewAnimation库中工作

android – 拖放不能在nhaarman的ListviewAnimation库中工作,第1张

概述我正在使用nhaarman的ListviewAnimation库 https://github.com/nhaarman/ListViewAnimations,效果很好. 但是我面临以下问题: 我面临的主要问题是,我无法调试我的代码.我已经将四个必需的库直接复制/粘贴到libs文件夹中.在任何listview方法(如onItemLongClick())中放置调试点都不起作用. 第二个问题是,拖放l 我正在使用nhaarman的ListvIEwAnimation库 https://github.com/nhaarman/ListViewAnimations,效果很好.

但是我面临以下问题:

我面临的主要问题是,我无法调试我的代码.我已经将四个必需的库直接复制/粘贴到libs文件夹中.在任何ListvIEw方法(如onItemLongClick())中放置调试点都不起作用.

第二个问题是,拖放ListVIEw在我的代码中不起作用.每当我尝试拖动任何列表项时,在删除列表项时,该项将采用与其拖动相同的位置.

这是我用过的代码:

ListvIEw.enableDragAndDrop();ListvIEw.setDraggableManager(new touchVIEwDraggableManager(        R.ID.List_row_draganddrop_textvIEw));ListvIEw.setonItemmovedListener(this);ListvIEw.setonItemLongClickListener(this);@OverrIDe    public voID onItemmoved(final int originalposition,final int newposition) {        if (mToast != null) {            mToast.cancel();        }        mToast = Toast.makeText(getApplicationContext(),"Moved"                + swingBottomInAnimationAdapter.getItem(newposition)                + newposition,Toast.LENGTH_SHORT);        mToast.show();    }    @OverrIDe    public boolean onItemLongClick(final AdapterVIEw<?> parent,final VIEw vIEw,final int position,final long ID) {        if (ListvIEw != null) {            ListvIEw.startDragging(position - ListvIEw.getheaderVIEwsCount());        }        return true;    }
解决方法

Whenever I try to drag any List item,on dropPing the List item,the item takes the same position from which it was dragged.

当然.处理位置变化是你的责任,你应该在onItemmoved回调中处理它:

@OverrIDepublic voID onItemmoved(final int originalposition,final int newposition) {    if (mToast != null) {        mToast.cancel();    }    mToast = Toast.makeText(getApplicationContext(),"Moved"            + swingBottomInAnimationAdapter.getItem(newposition)            + newposition,Toast.LENGTH_SHORT);    mToast.show();    // Adapt the following to your implementation    if (originalposition != newposition) {            YourObject item = (YourObject) yourAdapter.getItem(originalposition);            yourAdapter.moveItem(item,newposition);    }}

上面提到的方法看起来像:

public voID moveItem(YourObject item,int newIndex) {    if (mEntrIEs != null) {        mEntrIEs.remove(item);        mEntrIEs.add(newIndex,item);        notifyDataSetChanged();    }}

如果你浏览源代码,你会发现你正在拖动的是一个位图.列表项位于其原始位置.

总结

以上是内存溢出为你收集整理的android – 拖放不能在nhaarman的ListviewAnimation库中工作全部内容,希望文章能够帮你解决android – 拖放不能在nhaarman的ListviewAnimation库中工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1131214.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存