Android uses recyclerview to realize the functions of select all, top and drag

preface

Today, I'd like to share with you how to select all in recyclerview and how itemtouchhelper can realize sideslip deletion and drag functions. Comparison basis. I won't say much about the power of recyclerview. Among the new APIs released by the Android l SDK, the most interesting ones are recyclerview and cardview. According to the official statement, recyclerview is a more advanced and flexible version of listview, and there are too many things that can be customized.

effect:

Using recyclerview, we need to rely on

Project structure:

It is mainly to record the selected information stored in HashMap and send the notification with eventbus. Let's realize this effect step by step

The method is as follows

1. Let's create a new mainactivity layout

2. Let's build a listadapter adapter

3. We create new entity book and selectevent

4. Establish check@R_ 722_ 2419@_ Selector.xml selected style

5. Create an activity_ Main.xml layout

activity_ main_ Item layout

In this way, the recyclerview can select all, the itemtouchhelper can delete sideslip, and the drag function is completed.

Sample code download:

Project address: https://github.com/88ios/RecyclerViewCheckAll

Local download: click here

summary

The above is the whole content of this article. I hope the content of this article can bring some help to Android developers. If you have any questions, you can leave a message. Thank you for your support for programming tips.

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