0

I have recently started on Android development platform.

I could not able to find a built-in delete feature in the list view which allows user to delete the row like iOS tableview does as shown in the following figure.

What is the common/standard way of doing it in the Android?

enter image description here

casillas
  • 16,351
  • 19
  • 115
  • 215
  • 1
    you have to do it by custom way check this you will get an idea http://stackoverflow.com/questions/13412341/how-to-add-remove-item-from-listview-in-android-when-click-button-in-item-listvi/13412658#13412658 – Pavan Oct 09 '15 at 15:34
  • 1
    You delete by swiping the item left/right (well thats the most common way) and then a toast with an undo action. – Johan Oct 09 '15 at 15:35
  • Hi Johan, is there any example to share with? – casillas Oct 09 '15 at 15:37
  • 1
    http://stackoverflow.com/questions/14398733/remove-item-listview-with-slide-like-gmail – Johan Oct 09 '15 at 15:41
  • 1
    On top of the swipe-to-delete, it is generally expected that users can press and hold to select items. Once one or more items are selected, the action bar populates with relevant actions, sometimes including a trash can. – Jack Oct 09 '15 at 15:41

1 Answers1

0

You can implement a long click listener and set it to your listview:

listview.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int pos, long id) {
            // TODO Auto-generated method stub

            Log.v("long clicked","pos: " + pos);

            return true;
        }
    });

For instance, you can show a Contextual Menu Bar in the Action Bar or a Floating ContexTual Menu. You can also modify your adapter to change the item and show a "Delete", but this approach is not Android standard.

Regards,

lgallard
  • 462
  • 3
  • 10