I am trying to port some iOS functionality to Android.
I intent to create a table where on swipe to the left shows 2 button: Edit and Delete.
I have
If you use a RecyclerView
, try to use OnScrollListener
. Do something like this.
private class YourOnScrollListener extends RecyclerView.OnScrollListener {
private boolean directionLeft;
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (directionLeft) drawButtons();
//Draw buttons here if you want them to be drawn after scroll is finished
//here you can play with states, to draw buttons or erase it whenever you want
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dx < 0) directionLeft = true;
else directionLeft = false;
}
}