-5

I have to remove the single item from list view in android while clicking long click. Please let me suitable code for removing a item in list view? Here is the my code

        this.getListView().setLongClickable(true);
        this.getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // TODO Auto - generated method stub

            }
}
Chandrakanth
  • 3,711
  • 2
  • 18
  • 31

2 Answers2

1

Use remove() method in your ArrayAdapter.

yourarrayAdapter.remove(yourarrayAdapter.getItem([POSITION]));

OR

yourarrayList.remove([POSITION]);
yourarrayAdapter.notifyDataSetChanged();
LEADER
  • 113
  • 8
0

Try this in your click callback, to remove the view from its parent:

((ViewManager) parent).removeView(view);
Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70