public class SwipeDismissTouchListener
extends java.lang.Object
implements android.view.View.OnTouchListener
View.OnTouchListener
that makes any View
dismissable when the
user swipes (drags her finger) horizontally across the view.
For ListView
list items that don't manage their own touch events
(i.e. you're using
AdapterView.setOnItemClickListener(android.widget.AdapterView.OnItemClickListener)
or an equivalent listener on ListActivity
or
ListFragment
, use SwipeDismissListViewTouchListener
instead.
Example usage:
view.setOnTouchListener(new SwipeDismissTouchListener( view, null, // Optional token/cookie object new SwipeDismissTouchListener.OnDismissCallback() { public void onDismiss(View view, Object token) { parent.removeView(view); } }));
This class Requires API level 12 or later due to use of ViewPropertyAnimator
.
SwipeDismissListViewTouchListener
Modifier and Type | Class and Description |
---|---|
static interface |
SwipeDismissTouchListener.DismissCallbacks
The callback interface used by
SwipeDismissTouchListener to inform its client
about a successful dismissal of the view for which it was created. |
Constructor and Description |
---|
SwipeDismissTouchListener(android.view.View view,
java.lang.Object token,
SwipeDismissTouchListener.DismissCallbacks callbacks)
Constructs a new swipe-to-dismiss touch listener for the given view.
|
Modifier and Type | Method and Description |
---|---|
boolean |
onTouch(android.view.View view,
android.view.MotionEvent motionEvent) |
void |
performDismiss() |
public SwipeDismissTouchListener(android.view.View view, java.lang.Object token, SwipeDismissTouchListener.DismissCallbacks callbacks)
view
- The view to make dismissable.token
- An optional token/cookie object to be passed through to the callback.callbacks
- The callback to trigger when the user has indicated that she would like to
dismiss this view.