# DoubleStickyHeadersList **Repository Path**: baijuncheng-open-source/DoubleStickyHeadersList ## Basic Information - **Project Name**: DoubleStickyHeadersList - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-22 - **Last Updated**: 2024-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DoubleStickyHeadersList 一个OpenHarmony库,用于粘贴到列表顶部的双层节头。OpenHarmony小部件,特别用于显示具有多级分类的项目。 ![](samplePicture/sample.gif) # 使用 #### 1. 在项目中使用库。 添加Gradle: 添加下面的代码到`build.gradle`: ```xml dependencies { implementation 'com.gitee.baijuncheng-open-source:DoubleStickyHeaderList:1.0.1' } ``` #### 2.将`layout.xml`文件中的`ListContainer`替换为`com.kenber.view.DoubleStickyHeaderListView`。 ```xml ``` #### 3. 使`DoubleStickyHeaderListView`的`adapter`实现`doubleStickHeaderListAdapter`接口。您需要重写`getHeaderLevel(int position)`方法来告诉`DoubleStickyHeaderListView`哪个标头应该作为级别0或级别1粘滞,或者作为级别2不粘滞,重写`getHeader0Color()`表示级别0的头部绘制的颜色,`getHeader1Color()`表示级别1的头部绘制的颜色。 ```java public class ListAdapter extends ArrayAdapter implements DoubleStickHeadersListAdapter { ... @Override public int getHeaderLevel(int position) { return getItem(position).level; } @Override public int getHeader0Color() { return BG_COLOR_LEVEL_0; } @Override public int getHeader1Color() { return BG_COLOR_LEVEL_1; } } ``` #### 4.如果拥有头部列表,可以使用下面的接口设置头部的点击事件 ``` listView.setHeadClick(this); ``` #### 5.需要设置绘制区域的文字大小,可以使用下面的方法 ``` listView.setTextsize(16); ``` #### 6.注意事项 **该库最多实现两级吸顶,并且不能跳级(不能不设置一级直接设置二级)** 现在,一切都结束了。此库的示例可在`example`文件夹中找到。 License ======= Copyright 2016 Kenber 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.