Android Advanced UI Design Note 02: The GridView can be dragged to swap item locations

Source: Internet
Author: User

1. First we understand the concept of the GridView dragging:

(1) Get the item that we clicked on the GridView according to the X, y coordinates of the finger press.

(2) Finger Press when using handler and runnable to implement a timer, if the timing time is 1000 milliseconds, in 1000 milliseconds, if the finger lifted the removal timer, Not lifted and the finger clicked in the area where the GridView item is located, it means we've pressed the GridView item.

(3) If we press and hold item, hide item, and then use WindowManager to add an item's mirror to the screen to replace the item that was just hidden.

(4) When we move the finger on the screen, update the position of the item image, and then get the position to move to the GridView based on the coordinates of the x, Y, which we moved.

(5) to the GridView item too much time, may a screen display is not finished, we finger drag item mirror below the screen, to trigger the GridView want to scroll, similarly, when we finger drag item mirror above the screen, Triggers the GridView scroll down.

(6) GridView Exchange data, refresh the interface, remove the image of item.

2.

Android Advanced UI Design Note 02: The GridView can be dragged to swap item locations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.