question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

remove an listview item in swipeadater?

See original GitHub issue

I have a horizontal list view and for each item I want to delete it with swipe gesture. I put the delete logic in onOpen method, but seems it’s not working.

@Override
            public void onOpen(SwipeLayout layout) {
                 //when the BottomView totally show.
                Log.d("Position", Integer.toString(position));

                mPictures.remove(position);
                notifyDataSetChanged();

            }

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Michal-easycorecommented, Aug 3, 2015

Hey, don’t know guys if you are still facing this issue, but right now I am having exact same problem using lib version 1.2.0. I resolved the problem simulating removeAllSwipeListeners() by having my own List.

public class FixedSwipeLayout extends SwipeLayout {

private List<SwipeListener> swipeListeners;

public FixedSwipeLayout(Context context) {
    super(context);
    swipeListeners = new ArrayList<>();
}

public FixedSwipeLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    swipeListeners = new ArrayList<>();
}

public FixedSwipeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    swipeListeners = new ArrayList<>();
}

@Override
public void addSwipeListener(SwipeListener listener) {
    for (SwipeListener l : swipeListeners) {
        removeSwipeListener(l);
    }
    swipeListeners.clear();

    swipeListeners.add(listener);
    super.addSwipeListener(listener);
}

}

I think correctly solving this problem is to have Set instead of List inside SwipeLayout. I hope it will be fixed soon.

0reactions
basith0304commented, Jun 29, 2015

Hi,

When I’m using Kitkat Version . If i swipe the list item, delete & open button appeared and suddenly its closed .(Your Demo Application also same )other versions its working good .

Your Application Link : https://github.com/daimajia/AndroidSwipeLayout/releases/download/v1.1.8/AndroidSwipeLayout-v1.1.8.apk

Please help me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove ListView items in Android - Stack Overflow
You will want to remove() the item from your adapter object and then just run the notifyDatasetChanged() on the Adapter, any ListView s...
Read more >
Kotlin Swipe To Delete ListView Android Example Like Gmail
When the user swipes right or left to delete, system will pop up an Undo button, if user clicks this button system will...
Read more >
Add and Remove Items with ListView Control - Microsoft Learn
Learn how to add and remove an item with the Windows Forms ListView control by specifying the item and assigning properties to it....
Read more >
Finding the correct index to delete a listView item - Jazz.net
I dont know how to find an index of the listview in order to delete it. My actively populated ListView Items needs to...
Read more >
How to Remove ListView Item Divider in Android?
ListView in Android is generally used for displaying or listing items ... In this article, we will show you how you could remove...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found