Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit f050581

Browse files
author
Angad Singh
committed
chore: Added Implementation steps in Readme.md
1 parent 58bd518 commit f050581

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

Readme.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Android Library for Custom Switches.
55
[Angad Singh](https://www.github.com/angads25) ([@angads25](https://www.twitter.com/angads25))
66

77
### Benchmark:
8-
[![API](https://img.shields.io/badge/API-9%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=9) <a href="http://www.methodscount.com/?lib=com.github.angads25%3Afilepicker%3A1.1.1"><img src="https://img.shields.io/badge/Methods and size-271 | 43 KB-e91e63.svg"/></a>
8+
[![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14)
99

1010
### Where to Find:
11-
[ ![Download](https://api.bintray.com/packages/angads25/maven/filepicker/images/download.svg) ](https://bintray.com/angads25/maven/filepicker/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.angads25/filepicker/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.angads25/filepicker) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FilePicker-blue.svg?style=flat)](http://android-arsenal.com/details/1/3950)
11+
[![Download](https://api.bintray.com/packages/angads25/maven/Toggle/images/download.svg)](https://bintray.com/angads25/maven/Toggle/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.angads25/toggle/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.angads25/toggle)
1212

1313

1414
### Installation
@@ -18,7 +18,37 @@ Android Library for Custom Switches.
1818
compile 'com.github.angads25:toggle:1.0.0'
1919
```
2020

21+
### Usage
22+
23+
1. Start by adding a Switch (eg. LabeledSwitch) in your xml layout as:
24+
25+
```xml
26+
27+
<com.github.angads25.toggle.LabeledSwitch
28+
android:id="@+id/switch1"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:layout_margin="16dp"
32+
android:textSize="14sp"
33+
app:on="false"
34+
app:colorBorder="@color/colorAccent"/>
35+
```
36+
37+
2. To the reference of Switch in your Activity/Fragment class and set a ToggleListener to it as below:
38+
39+
```java
40+
LabeledSwitch labeledSwitch = findViewById(R.id.switch1);
41+
labeledSwitch.setOnToggledListener(new OnToggledListener() {
42+
@Override
43+
public void onSwitched(LabeledSwitch labeledSwitch, boolean isOn) {
44+
// Implement your switching logic here
45+
}
46+
});
47+
```
48+
That's It. All your switching callbacks would be handled in onSwitched method, isOn will provide the current state of the switch.
49+
2150
### Switches Available
2251

2352
* Labeled Switch
2453

54+
![Labeled Switch](https://raw.githubusercontent.com/Angads25/android-toggle/develop/screenshots/version%201/device-2018-02-21-233623.png)

0 commit comments

Comments
 (0)