Remove item listview with Slide - Like Gmail

前端 未结 4 1430
北恋
北恋 2020-12-23 02:51

I am developing an application with a shop list in a listview. I need that when I swipe the item of listview to the right(or left), this item should get deleted

4条回答
  •  半阙折子戏
    2020-12-23 03:15

    Answer by Android-Developer points to Roman Nurik's code in gist.github.com. This code is out of date. He uses this Swipe to Dismiss listener in his open sourced project Dash Clock.

    There are some things you should know, before you use the code in Gist.github.com.

    1. The outdated code in gist.Github is very sensitive to touches. If you keep on tapping an item in the ListView, it will be deleted. In the updated code he fixed the fling sensitivity.
    2. This listener doesn't work well if you have dividers declared in ListView. If you want dividers, declare them in the ListItem layout.
    3. This code is still in beta. Caveat emptor.

    So I recommend using the updated code. You can find the updated source here.

提交回复
热议问题