Skip to content

Listener for ListViews and RecyclerViews. Don't dismiss while swiping

Compare
Choose a tag to compare
@wmora wmora released this 20 Nov 22:03
· 248 commits to master since this release

You can attach the Snackbar to a AbsListView (ListView, GridView) or a RecyclerView.

Snackbar.with(getApplicationContext()) // context
    .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar
    .text("This is a multi-line snackbar. Keep in mind that snackbars are " +
        "meant for VERY short messages") // text to be displayed
    .duration(Snackbar.SnackbarDuration.LENGTH_LONG)
    .animation(false) // don't animate it
    .attachToAbsListView(listView) // Attach to ListView - attachToRecyclerView() is for RecyclerViews
    .show(this); // where it is displayed

A Snackbar won't be dismissed while it is being swiped