# SlideSwitch **Repository Path**: HarmonyOS-tpc/SlideSwitch ## Basic Information - **Project Name**: SlideSwitch - **Description**: 一个开关,可以滑动它来打开或关闭 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 2 - **Created**: 2021-04-01 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-button **Tags**: None ## README # SlideSwitch 一个开关,可以滑动它来打开或关闭 # 效果图
# 导入项目 方式一: 通过library生成har包,添加har包到libs文件夹内 在entry的gradle内添加如下代码 ```gradle implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) ``` 方式二: ```gradle allprojects{ repositories{ mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:SlideSwitch:1.0.3' ``` # 用法 您可以像下面的示例一样在xml中定义一个Slideswitch ```xml ``` 您可以通过这种方式在jave代码中初始化状态(打开或关闭) ```java mSlideSwitch.setState(false); ``` 监听滑动开关的变化 ```java mSlideSwitch.setSlideListener(new SlideSwitch.SlideListener() { @Override public void open(SlideSwitch slideSwitch) { } @Override public void close(SlideSwitch slideSwitch) { } }); ``` 开启或者禁止滑动 ```java mSlideSwitch.setState(false); mSlideSwitch.setState(true); ``` ## LICENSE Copyright 2015 Quinn Chen 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.