I would like to swipe the first item on the SwipeListView on Activity start up to show the user that the SwipeListView is swipe-able.
How can I perform this action programmatically with this UI element?
I tried to use the
swipeListView.openAnimate(position)
that was proposed here in the answer, but for some reason even after I populate the adapter with data-items... when I debug and reach this code section the swipeListView doesn't see item in it, and fails with NullPointerException.
Well, I realized that the reason there were no items in the adapter because it's not yet created in onCreate, so I moved this code to method:
public void onWindowFocusChanged(boolean hasFocus){}
of my activity, now it runs but still fails on the following method of the SwipeListView library:
private void resetCell() {
if (downPosition != ListView.INVALID_POSITION) {
if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_CHOICE) {
backView.setVisibility(View.VISIBLE);
}
frontView.setClickable(opened.get(downPosition));
frontView.setLongClickable(opened.get(downPosition));
frontView = null;
backView = null;
downPosition = ListView.INVALID_POSITION;
}
}
The reason for this is that when this method is running the frontView object is never set and those it null.
For openining the item you should use
swipeListView.openAnimate(position)
For closing the item you can use on of this:
swipeListView.closeAnimate(position);
swipeListView.closeOpenedItems();
Here is some code from working project:
private BaseSwipeListViewListener albumsLIstener = new BaseSwipeListViewListener() {
@Override
public void onClickFrontView(int position) {
if (albumsListsView.isOpened(position)) {
albumsListsView.closeAnimate(position);
} else albumsListsView.openAnimate(position);
}
@Override
public void onClickBackView(int position) {
if (albumsListsView.isOpened(position)) {
albumsListsView.closeAnimate(position);
} else albumsListsView.openAnimate(position);
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With