Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 22. Drag-and-drop > Listening for drag-and-drop events

22.6. Listening for drag-and-drop events

Recall that a drag-and-drop operation begins with a call to startDrag() from a source view. After the operation has started, the system begins sending drag events to views. Views that want to participate in the drag operation and accept events and the dropped data must first listen for events. There are two approaches for listening for drag events:

  • Implement android.view.View.OnDragListener and its onDrag(View v, DragEvent event) method. You set the view’s drag listener by calling the View.setOnDragListener() method.

  • Use the view’s callback method by subclassing View and overriding the onDragEvent(DragEvent event) callback.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint