# DropDownView **Repository Path**: ts_ohos/DropDownView ## Basic Information - **Project Name**: DropDownView - **Description**: A simple drop down view with built-in animations. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-11 - **Last Updated**: 2022-09-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DropDownView 本项目是基于开源项目DropDownView进行harmonyos化的移植和开发的,可以通过项目标签以及 [github地址](https://github.com/AnthonyFermin/DropDownView) 移植版本:源master1.0.1版本 ## 项目介绍 ### 项目名称:DropDownView ### 所属系列:harmonyos的第三方组件适配移植 ### 功能: 实现可下拉列表控件。 ### 项目移植状态:完全移植 ### 调用差异:基本没有使用差异,请参照demo使用 ### 原项目Doc地址:https://github.com/AnthonyFermin/DropDownView ### 编程语言:java ### 项目截图(涉及文件仅供demo测试使用) ## 效果演示 ![demo运行效果](img/demo.png) ![demo运行效果](img/demo.gif) ![demo运行效果](img/demo2.gif) ## 安装教程 #### 方案一 可以先下载项目,将项目中的library库提取出来放在所需项目中通过build配置 ```Java dependencies { implementation project(":library") } ``` #### 方案二 - 1.项目根目录的build.gradle中的repositories添加: ```groovy buildscript { repositories { ... mavenCentral() } ... } allprojects { repositories { ... mavenCentral() } } ``` - 2.开发者在自己的项目中添加依赖 ```groovy dependencies { implementation 'com.gitee.ts_ohos:dropdownview:1.0.1' } ``` # How to use XML中添加下拉框控件: ```xml ``` 下拉控件加入列表项,并且在点击后触发显示: #### Bind views: ``` dropDownView = (DropDownView) findViewById(R.id.drop_down_view); collapsedView = LayoutInflater.from(this).inflate(R.layout.view_my_drop_down_header, null, false); expandedView = LayoutInflater.from(this).inflate(R.layout.view_my_drop_down_expanded, null, false); ``` #### Set header and expanded views to DropDownView: ``` dropDownView.setHeaderView(collapsedView); dropDownView.setExpandedView(expandedView); ``` #### Call expand or collapse: ``` collapsedView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (dropDownView.isExpanded()) { dropDownView.collapseDropDown(); } else { dropDownView.expandDropDown(); } } }); ``` #### Optional DropDownListener: ``` /** * A listener that wraps functionality to be performed when the drop down is successfully expanded * or collapsed. */ private final DropDownView.DropDownListener dropDownListener = new DropDownView.DropDownListener() { @Override public void onExpandDropDown() { adapter.notifyDataChanged(); headerChevronIV.createAnimatorProperty().rotate(ANGLE).start(); } @Override public void onCollapseDropDown() { headerChevronIV.createAnimatorProperty().rotate(ANGLE).start(); } }; ... dropDownView.setDropDownListener(dropDownListener); ``` #### Done! # License Copyright 2017 DropDownView Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```