Android enables listview to slide left and right, delete and edit

Sometimes, in order to meet the requirements of the project and complete the designed user interaction experience, these views are not transformed into the desired effect.

The Android native listview does not support left-right sliding, but seeing that the contacts can slide left-right on the wechat phonebook, they realized it through their own ideas and ideas.

Idea: 1. Get the X and Y positions when the finger is placed on the screen, and judge the position of the clicked listview. 2. Judge the sliding direction. If it is up and down, the touch event will be handed over to listview for processing; If it is left-right, the listview is prohibited from sliding. 3. Move the selected view according to the movement of the finger. 4. After sliding, return the view to its original position. 5. Tell the user whether to slide left or right through the incoming listener.

design sketch:

Code of the new listview:

Test the activity code of listview:

Listview layout file:

Item layout of listview:

Other classes used in the code are as follows in the previous article: https://www.oudahe.com/p/23078/

Reprinted from: http://blog.csdn.net/qxs965266509

The above is the whole content of this article. I hope it will be helpful to your study.

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
分享
二维码
< <上一篇
下一篇>>