Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the side slip menu control ASwipeLayout

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use the side slide menu control ASwipeLayout, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Preface

The advantages of this control are:

1. No matter in RecyclerView,ListView, or LinearLayout, etc., as long as ViewGroup uses this control to achieve side sliding.

two。 The gesture sliding conflict of the control has been resolved, and there will be no smooth sliding of controls such as nesting to ScrollView.

3. The control is easy to use. You only need to coat the control on the xml and access it for a second.

4. Click on the event is very convenient, the original what to write the way to write

1. Effect picture

two。 The way to use it is actually quite simple. When designing, you just think about how to get it simple.

2.1 Import the library:

Step 1. Add it in your root build.gradle at the end of repositories:

Allprojects {repositories {... Maven {url 'https://jitpack.io'}

Step 2. Add the dependency

Dependencies {implementation 'com.github.WelliJohn:ASwipeLayout:0.0.2'}

2.2 add the following code to the root layout that requires a side-sliding layout, and note that the comments can be customized:

/ / here is something to implement your main item, add freely according to your project / / here is the menu on the right side of the implementation, and casually add according to your project

Note that ll_content,right_menu_content is a must here, the corresponding layout of this id should not be changed by yourself, it will be released in the future, at present, in general, you only need to customize the content of the main item and the right menu bar, here I also omit to define some additional custom view, simply use id to distinguish the main item and the right menu.

3. Because there is a case of reusing Item in RecyclerView, the solution to this situation

Because item reuse will cause other Item to slide out of menu when we slide out of a menu and slide RecyclerView up and down again, that is, item reuse leads to layout confusion, so for this type of problem, I have provided the OnSwipeStateChangeListener interface here, where you can record the sliding state. In the onBindViewHolder method, set whether Item enables menu or disables menu according to the status:

@ Override public void onBindViewHolder (ViewHolder holder, int position) {final Person person = mDatas.get (position); holder.scrollDelLl.setOpen (person.isOpen ()); holder.scrollDelLl.setOnSwipeStateChangeListener (new OnSwipeStateChangeListener () {@ Override public void onSwipeStateChange (boolean open) {person.setOpen (open);}});}

The above code can solve the problem of layout confusion caused by Item reuse (poop no longer has to worry about RecyclerView reuse).

4. If you have new requirements or bug during the use of the project, you can mention your requirements or issue on github.

The above is all the contents of the article "how to use the side-slide menu control ASwipeLayout". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report