ListView Swipe to Delete Library

ListView Swipe to Delete is an Android library which offers a list view navigation mode similar to application.

You can:

The library supports both ListView and ExpandableListView navigations. See /demo folder for example how to use.

How to use

  1. Create own XML layout for a list view item. The library will later attach it to its XML templates for:

    • item with hidden context menu
    • completed item.
  2. Define item's context menu if needed. It can be edit or share item's content, for instance. Menu is initially hidden and is shown if item is tapped. For every menu item you need to specify icon and action:

    private ArrayList<MenuItemDesc> fillMenu() {
        ArrayList<MenuItemDesc> items = new ArrayList<MenuItemDesc>();
        MenuItemDesc itemEdit = new MenuItemDesc();
        MenuItemDesc itemShare = new MenuItemDesc();
        return items;

    Received collection of menu items descriptions will later be used to create menu ImageViews.

  3. In activity's onCreate() method get a reference to a list view:

    list = (ListView) findViewById(;
  4. Then, you need to create a class to handle menu items actions and pass a list view reference to it:

    listHandler = new ItemListHandler(list);
    public class ItemListHandler extends ItemBaseListHandler {
        public ItemListHandler(ListView list) {
        public void onItemMenuAction(int position, String action) {
            if (action.equals(getString(R.string.editAction))) {
                //TODO do smth
            else if (action.equals(getString(R.string.shareAction))) {
                //TODO do smth
  5. Create list adapter. You need to pass:

    • an ID of your list item's content XML layout
    • a list of menu items descriptions
    • a list handler

      listAdapter = new ItemListAdapter(R.layout.item, menuItems, listHandler);

      Then you need to override adapter's getView() method to set list item's data:

      public View getView(final int position, View convertView, ViewGroup parent) {
          View view = super.getView(position, convertView, parent); //parent adapter is responsible for view creation and list animations
          Item dt = (Item) data.get(position);
          TextView text = (TextView) view.findViewById(;
          return view;
  6. Create list manager class responsible for swipe and shake detection:

    listManager = new ItemListManager(this, listHandler, true); //the 3rd parameter in constructor enables shake detection