Android listview and GridView drag shift implementation code

You must be familiar with the drag and drop location of listview. Good software uses such functions, such as Sohu, Netease, Baidu, etc., but Baidu has a better user experience and is not eccentric. Here are some examples:

The effect looks ok. If you think it's good, remember to praise one

Next, let's modify and simulate Baidu. Who makes Baidu so arrogant. Idea: when clicking the drag icon, every time I move, as long as the dragposition changes, that is, I move to the next position, then I exchange and execute update. In addition to the first move, the display of the mapping source should be removed after each exchange, In this way, users feel that the vacancy here is prepared for me, which is more humanized. The implementation is not complicated, provided that you have to master the above operation. The source code is as follows; [java]

How about this effect? It seems to be more user-friendly than the above effect. My operation may be a little fast. If you don't believe it, experience it on your mobile phone. That's all about listview drag. If there are deficiencies, please innovate yourself

Next we will simply explain the drag and drop of GridView. Because these are used in the project, so we should do it in a comprehensive way. OK, let's go on to look at it. First, principle is the same as dragging the image, recording the drag position, and calling notifyDataSetChanged to update UI.. GridView is different from X. The y value jointly obtains the clicked position and the moved position, and the listview does not involve the X coordinate. Well, I won't show you the initial original movement, and the effect is not very friendly. I directly show the method of updating from time to time. The effect class is the same as the listview updating from time to time above. The principle is the same. Let's look at the code directly. [Java]

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>