AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
The DropTarget interface defines the following methods: boolean acceptDrop (DragSource source, int x, int y, int xOffset, In code, what’s going on is that the Trash view implements the DropTarget interface. Since it is a trash icon, you know that it means the icon being dragged will be removed from the workspace. The red color gives you a good indication that something will happen if you drop the icon there. If you drag an icon over that icon, you will see a change in the color of the view being dragged. You should see that a Trash icon appears. In the Launcher, when you start dragging an icon, check out what happens at the bottom of the screen. Here’s how DropTargets figure into the Android Launcher. The one object I did not explore fully was the DropTarget. The Launcher object model includes objects like DragLayer, DragSource, DragController, and DropTarget. ![]() In an earlier note (see “ Moving Views In Android – Part 2“), I had written up how the Android Launcher app supports moveable views using the touch interface. The classes in this app are derived from the Android Launcher application. The other two show the background color changes in the drop zones as you move over them. Figure 2 shows the menu where you can add other objects and enable and disable the orange drop zone. There are two red drop zones and one orange drop zone. Figure 1 is what it looks like when it launches. The figures show what the app looks like at various points. As you drag views around the screen, the drop zones light up to indicate that they are places where you can drop objects. In my example, I called those areas DropZones. I also worked out how you can have different drop behavior for different areas of the screen. I now understand how views can be placed on the screen and moved by touching them. I have come to the end of my work on drag-drop in Android.
0 Comments
Read More
Leave a Reply. |