如何替换listview中的新项目

时间:2013-09-12 11:41:37

标签: android android-listview

我搜索了StackOverflow,但我没有找到任何选择的解决方案。我有ListView,我希望delete(like swipe the listview item)在ListView中listviewitemreplace with new image or show new image at that deleted position,该怎么做?任何人都可以帮助解决这个问题....

我试过这个

ImageView imageView = (ImageView) lView.getChildAt(position);
imageView.setImageResource(R.drawable.redo);

但无法获得结果!!

5 个答案:

答案 0 :(得分:2)

您可以通过Chat Hasse查看此博客

http://graphics-geek.blogspot.in/search?updated-max=2013-06-28T10:23:00-07:00&max-results=7

还有解释和下载版本的端口代码。该示例显示了如何使用文本滑动和删除列表项。

例如,检查我的答案@

Android listview row delete animation

维护一份drawables列表。根据列表视图中的刷卡位置从列表中删除drawable。通过调用适配器上的notifyDataSetChanged刷新列表。

答案 1 :(得分:1)

您可以在github项目之后尝试这个。

你可以找到你所要求的确切内容,你可以在这两个按钮中找到很多选项,例如轻扫以解除和动画解雇..

撤消选项出现在操作栏中。撤销也可用于基于时间..

ListViewAnimationWithRedo source

这里提供Google Play现场演示......

The working demo of listview redo

答案 2 :(得分:0)

你必须刷新适配器。试试这个:

 adapter.notifyDataSetChanged();

答案 3 :(得分:0)

您需要重新创建适配器并调用notifyDataSetChanged()。

myadapter=new myListViewAdapter(....);
myadapter.notifyDataSetChanged();

答案 4 :(得分:0)

我希望您维护数据库以插入和删除图像......如果你这样...... 然后通过在数据库中使用游标,您可以获取方法中列的所有值,并在删除或插入图像后立即调用该方法