Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.samsaodev:swipeablelistitem

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.samsaodev:swipeablelistitem

A library that allows swiping views for Android's recyclerviews

  • 1.0.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Swipeable List Item

A library that allows recycler views with swiping items to right or left for Android.

Swipe action

Supported Android versions

3.1.x and higher

Adding to your project

Add the dependency to your build.gradle:

dependencies {
	compile 'com.samsaodev:swipeablelistitem:1.0.0'
}

Usage

  1. Create a view to be your RecyclerView's cell and extend it from SwipeableView. Then implement the method 'getContent(ViewGroup parent)' to provide your cell's layout. Your class should look like this:
public class ListItem extends SwipeableView {

    public ListItem(Context context) {
        super(context);
    }

    @Override
    public View getContent(ViewGroup parent) {
        return LayoutInflater.from(getContext()).inflate(R.layout.view_list_item, this, false);
    }
}
  1. Add the following line to your RecylerView's setup:
recyclerView.addOnItemTouchListener(new SwipeableListOnItemTouchListener());
  1. To avoid problems with your list's cell recycling, call this every time you setup your cell in your ViewHolder class.
mListItem.resetSwipe();
  1. Set a listener to your cell to know when the user swiped to left, to right, or clicked on it. Example:
listItem.setRightSwipeListener(new RightSwipeListener() {
            @Override
            public void onRightSwipe() {
                //Do something
            }
        });

If you don't add a swipe listener to a certain direction, it it the same as disabling it.

Customization

You can customize the views that show behind your cell when you swipe.

  • Change the background
setRightSwipeBackground(ContextCompat.getDrawable(getContext(), R.color.red));
  • Set a label:
setRightSwipeText("delete");
setRightSwipeTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
setRightSwipeTextSize((int) getResources().getDimension(R.dimen.font_size));
setRightSwipeTextTypeface(getTypeface());
  • Set an icon
setLeftDrawable(ContextCompat.getDrawable(getContext(), android.R.drawable.ic_delete));
  • Set a custom view
setRightCustomView(LayoutInflater.from(getContext()).inflate(R.layout.custom_view, this, false));

License

SwipeableListItem is released under the MIT license. See the LICENSE file for details.

FAQs

Package last updated on 27 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc