# expandable-recycler-view **Repository Path**: chinasoft5_ohos/expandable-recycler-view ## Basic Information - **Project Name**: expandable-recycler-view - **Description**: 可折叠的列表菜单 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-07-17 - **Last Updated**: 2022-06-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # expandable-recycler-view #### 项目介绍 - 项目名称:expandable-recycler-view - 所属系列:openharmony的第三方组件适配移植 - 功能:可折叠的列表菜单 - 项目移植状态:主功能完成 - 调用差异:菜单展开滑动时,会自动折叠滑出屏幕的菜单 - 开发版本:sdk6,DevEco Studio2.2 Beta1 - 基线版本:Release 1.5 #### 效果演示 ![art1](arts/arts1.gif) #### 安装教程 1.在项目根目录下的build.gradle文件中, ```groovy // 添加maven仓库 repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } ``` 2.在entry模块的build.gradle文件中, ```groovy // 添加依赖库 dependencies { implementation 'com.gitee.chinasoft_ohos:expandable-recycler-view:1.0.0' } ``` 在sdk6,DevEco Studio2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 添加布局 ``` xml ``` 创建对象并设置参数 **相关方法:** * **setFatherData** 设置父菜单数据 * **setChildData** 设置子菜单数据 ```java private void initView() { listContainer = (MultiTypeAndCheckContainer)findComponentById(ResourceTable.Id_multiType_container); listContainer.setFatherData(getData()); listContainer.setChildData(getChildMap()); backButton = (Button)findComponentById(ResourceTable.Id_backButton); backButton.setClickedListener(new Component.ClickedListener() { @Override public void onClick(Component component) { terminateAbility(); } }); } private List getData() { ArrayList data = new ArrayList<>(); VectorElement vectorElementLabel = new VectorElement(getContext(),ResourceTable.Graphic_ic_arrow_down); VectorElement vectorElementRock = new VectorElement(getContext(),ResourceTable.Graphic_ic_electric_guitar); VectorElement vectorElementJazz = new VectorElement(getContext(),ResourceTable.Graphic_ic_saxaphone); VectorElement vectorElementClassic = new VectorElement(getContext(),ResourceTable.Graphic_ic_violin); VectorElement vectorElementSalsa = new VectorElement(getContext(),ResourceTable.Graphic_ic_maracas); VectorElement vectorElementBluegrass = new VectorElement(getContext(),ResourceTable.Graphic_ic_banjo); data.add(new ExpandFatherItem("0",vectorElementRock,"Rock",vectorElementLabel)); data.add(new ExpandFatherItem("1",vectorElementJazz,"Jazz",vectorElementLabel)); data.add(new ExpandFatherItem("2",vectorElementClassic,"Classic",vectorElementLabel)); data.add(new ExpandFatherItem("3",vectorElementSalsa,"Salsa",vectorElementLabel)); data.add(new ExpandFatherItem("4",vectorElementBluegrass,"Bluegrass",vectorElementLabel)); return data; } /** * 填充子组件数据 * * @param name name * @return List */ private List getChildData(String[] name) { ArrayList data = new ArrayList<>(); for (int i = 0; i < name.length; i++) { data.add(new ExpandChildItem(name[i])); } return data; } /** * 子组件数据绑定到指定的父组件上 * * @return Map */ private Map> getChildMap() { Map> childMap = new HashMap<>(); childMap.put("0",getChildData(ChildData.ROCK_CHILD)); childMap.put("1",getChildData(ChildData.JAZZ_CHILD)); childMap.put("2",getChildData(ChildData.CLASSIC_CHILD)); childMap.put("3",getChildData(ChildData.SALSA_CHILD)); childMap.put("4",getChildData(ChildData.BLUEGRASS_CHILD)); return childMap; } public class ChildData { public static final String[] ROCK_CHILD = {"Queen","Styx","REO Speedwagon","Boston"}; public static final String[] JAZZ_CHILD = {"Miles Davis","Ella Fitzgerald","Billie Holiday"}; public static final String[] CLASSIC_CHILD = {"Ludwig van Beethoven","Johann Sebastian Bach", "Johannes Brahms","Giacomo Puccini"}; public static final String[] SALSA_CHILD = {"Hector Lavoe","Celia Cruz","Willie Colon","Marc Anthony"}; public static final String[] BLUEGRASS_CHILD = {"Bill Monroe","Earl Scruggs","Osborne Brothers","John Hartford"}; private ChildData() { } } ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.0 #### 版权和许可信息 Copyright (c) 2016 Amanda Hill and thoughtbot, inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.