Samantha
Samantha

Reputation: 199

Remove element from android listview

I am trying to create a list view that can support side swipe. I want the user to be able to drag a listview element to the right and off screen reveling a delete button below. The user should be able to click the delete button to remove that element from the listview. I have been following http://www.youtube.com/watch?v=YCHNAi9kJI4 but just need help on adding the delete button to the background. Any help?

Upvotes: 0

Views: 167

Answers (1)

TAH62K
TAH62K

Reputation: 421

in your Adapter fill() write this code

imgDeleteBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) { 

                 adapter.remove(item);

            }
        });

Upvotes: 12

Related Questions